<li class="ui-li ui-li-static ui-body-c">
<p class="ui-li-aside ui-li-desc"></p>
<span id="122"></span>
<h3 class="ui-li-heading"></h3>
<p class="ui-li-desc"></p>
<p class="ui-li-desc"><a class="ui-link">Report</a></p>
</li>
So here is my HTML markup.
Goal: I need JQuery code that will give me the id value of the <span> element (so in this case: 122) within the same <li>, when I click the <a> in that same <li>.
How would I do this?
Thanks!
Assuming you only have one span tag in your list items, you should be able to get your span's id with this:
$('a.ui-link').click(function(){
var id = $(this).closest('li').find('span:first').attr('id');
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With