Using .data to add data attribute using jQuery -
i have 2 spans on site:
<span class="view-toggle"></span>
and i'd firstly set data-status="inactive"
(to clear of settings), , add data-status="active"
1 element.
i have following:
$('.view-toggle').find().data("status","inactive"); $(button).data( "status", "active");
i can confirm $(button)
correctly identifies 1 span want add active
to.
i'm not getting console errors, i'm not getting addition of data attributes.
am using data()
incorrectly?
to value of attribute :
<strong id="the_id" data-original-title="i need this"> $('#the_id').data('original-title');
to set value of attribute
$('#div').attr(attname,attvalue);
Comments
Post a Comment