I have got the following code :
<ul>
<li class="jstree-leaf" kids="0" range="5-7" name="mars" public_id="mars_05" ra_depth="5">
<a href="#"><ins class="jstree-icon"> </ins>mars</a>
</li>
<li class="jstree-leaf" kids="0" range="8-10" name="pluto" public_id="pluto_8" ra_depth="5">
<a href="#"><ins class="jstree-icon"> </ins>pluto</a>
</li>
</ul>
I need to get the ra_depth
attribute value of a particular <li>
by using it's name
attribute value.
I tried the code below but it's not working:
alert(li[name='"+myarray[0]+"'].attr("ra_depth"));
myarray[0]
contains the value "pluto".
Is there anything I am missing?
You forget $(
in your selector. Check out my sample and this jsFiddle Demonstration
alert($("li[name='"+myarray[0]+"']").attr("ra_depth"));
alert($('li[name="'+myarray[0]+'"]').attr("ra_depth"));
You are missing the actually jQuery function around your selector:
alert($("li[name='"+myarray[0]+"']").attr("ra_depth"));
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