skip to Main Content
<a data-ca-action="1427202" title="deneme123">deneme123</a>

I need get data-ca-action value (1427202) with title value (deneme123) how can I do this with jquery?

I’m try this: $("a").$("[title=deneme123]") but I need more detail because I can’t set up the logic of the code I need to write

2

Answers


  1. something like that

    const res = $("a[title='deneme121']").data('ca-action')
    $('#resultView').text(`$("a[title='deneme121']").data('ca-action') -> ${res}`)
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <div style="display: none">
      <a data-ca-action="1427202_1" title="deneme121">deneme121_text</a>
      <a data-ca-action="1427202_2" title="deneme122">deneme122_text</a>
      <a data-ca-action="1427202_3" title="deneme123">deneme123_text</a>
    </div>
    
    <div id="resultView"></div>
    Login or Signup to reply.
  2. Use attr

    JQuery('a[title="deneme123"]').attr('data-ca-action')
    

    See this link

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search