Selecting html elements with jquery based on div and some other attribute -


this question has answer here:

i have html code:

<p class="test" data-id=1>some value</p>  <p class="test" data-id=2>some value</p>  <p class="test" data-id=3>some value</p>  <p class="test" data-id=4>some value</p> 

how can select <p> element based on data-id?

with jquery:

alert($("p[data-id='1']").html()); 

demo

jquery - attribute selector


Comments

Popular posts from this blog

iphone - Three second countdown in cocos2d -

hyperlink - how to do url routing in php -

c++ - CryptStringToBinary API behavior -