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

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -