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

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -