Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change HTML attribute with jQuery

I am using jQuery 1.4.4. and I have this source code:

<div id="area1">
    <ul id="testlist" data-filter="false">

    </ul>
</div>

How can I change the data-filter attribute to true in jQuery? I tried for example:

$('#testlist').attr("data-filter").val(true);

but it does not work.

Anyone an idea?

Best Regards.

like image 643
Tim Avatar asked Nov 28 '22 19:11

Tim


1 Answers

The syntax for attr is $.attr(attributeName, value);. Try this:

$('#testlist').attr("data-filter", true);
like image 128
Jonathon Bolster Avatar answered Dec 05 '22 17:12

Jonathon Bolster