javascript - jQuery : select all element with custom attribute -


possible duplicate:
jquery, select attribute value, adding new attribute
jquery - how select attribute

please consider code:

<p>11111111111111</p> <p mytag="nima">2222222222</p> <p>33333333333</p> <p mytag="sara">>4444444444</p> 

how can select p tag attribute mytag?

thanks

use "has attribute" selector:

$('p[mytag]') 

or select 1 attribute has specific value:

$('p[mytag="sara"]') 

there other selectors "attribute value starts with", "attribute value contains", etc.


Comments

Popular posts from this blog

json - Zend error Connection -

javascript - Trigger mouseenter when an animated element touches mouse -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -