Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing the inner tags class of a tag using jquery or javascript

I have the following code:

<li id="toto" class="jstree-leaf">
    <ins class="jstree-icon2">&nbsp;</ins>
    <a class=""><ins class="jstree-icon2">&nbsp;</ins>Story B</a>
</li>

I need to change the class of the <ins> tags for a specific <li>. I need to access the <li> id and then change the class of all <ins> tags found inside it

I would appreciate it if someone could show me the right way to do that.

Thanks a lot..

like image 723
tanya Avatar asked Feb 22 '23 12:02

tanya


1 Answers

You can add and remove classes for the ins tags like this, using jQuery:

$('#toto ins').removeClass('oldClass').addClass('newClass');
like image 199
wsanville Avatar answered May 07 '23 21:05

wsanville