javascript - JQuery .data() not fetching values after I change them -
i have data attribute called registeredteacherid. reason values aren't getting fetched correctly after update them. here general idea of i'm doing.
var registeredteacherid = $(eventpanel).data('registeredteacherid'); // work...then $(eventpanel).data('registeredteacherid', response.teacherid); // @ point sets new value in ie debugger window // more work // fetch value again , still shows old value var registeredteacherid = $(eventpanel).data('registeredteacherid');
the data
function not change value of data-*
attribute, give access these values.
you can change values , new data, , if want change content of data-*
attribute can use attr
function:
console.log($('div').data('content')); console.log($('div').attr('data-content')); $('div').data('content', 'some new content'); console.log($('div').data('content')); console.log($('div').attr('data-content'));
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div data-content="this content">text</div>
Comments
Post a Comment