JqueryNo Comments

default thumbnail

Like toggleSlide or toggleClass, we can toggle the attribute in jquery easily. If you want to add or remove any attribute in html element, try below code.


    <li id="item1">Home</li>


If you want to add data-target attribute in first item of ul

    $('#item1').attr('data-target', function(index, attr){
        return attr == '2' ? null : '2';

Be the first to post a comment.

Add a comment