How to get html tag based on attribute text in Jquery ? [Resolved]

Posted by Nandkishorre under jQuery on 1/20/2016 | Points: 10 | Views : 476 | Status : [Member] | Replies : 1
Hi Team.
I have data like below format.


<span id="1" dnd-draggable="{value:'a',text:'apple'}"/>
<span id="2" dnd-draggable="{value:'b',text:'bat'}"/>

here i want to get 'span' tag based on 'value' in dnd-draggable attribute.

for example:

if i give 'a', i will get first 'span' tag.




Thanks
Nanda Kishore.CH




Responses

Posted by: Rajeeshmenoth on: 1/20/2016 [Member] Starter | Points: 50

Up
0
Down

Resolved
Hi,

Check this example.


$("span").filter(function()
{
return ($(this).text().indexOf('a') > -1)
});

Reference :

http://jsperf.com/jquery-contains-vs-filter

Thanks
RajeeshMenoth (Rajeesh M R)

Tech Blog

Nandkishorre, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response