javascript - get <cite> tag value Onmousedown event -
html code looks like:
<ul> <li class="result"> <h3 class="title"><a class="someclass" href="url">sometext</h3> <cite class="url">cite url-1</cite> </li> <li class="result"> <h3 class="title"><a class="someclass" href="url-1">some more text</h3> <cite class="url">cite url-2</cite> </li> </ul>
i have cite value(cite url) on click of href. like:
$('a[class="someclass"]').mousedown(function() { console.log($('cite').text()) //if first link clicked cite url-1 should returned }
how cite tag value in case?
i'd suggest:
$('.someclass').click(function(e){ e.preventdefault(); // prevent click reloading page or navigating var cite = $(this).closest('li').find('cite'); console.log(cite.text()); });
references:
Comments
Post a Comment