html - How to detect last update in Javascript? -


have 2 labels in html allows user choose 1 number in each. how check box entered last , value entered in javascript? also, how can change value of user entered if want to?

<div class="text1">    <%: html.editorfor(x => x.decimal) %> </div>   <div class="text2">    <%: html.editorfor(x => x.decimal) %> </div> 

how can find textbox latest changed? doing right?

   var change1 = document.getelementbyid('text1').lastmodified;    var change2 = document.getelementbyid('text2').lastmodified;    if(change1.value > change2.value)     //do 

like this

window.onload = function(){ var 1 = document.getelementsbyclassname("text1")[0].children[0]; var 2 = document.getelementsbyclassname("text2")[0].children[0];  var lastchanged = null; var input1value, input2value;  one.onkeypress = function(e){     input1value = e.target.value;     lastchanged = 1;     console.log("lastchanged ", lastchanged, " value ", input1value); };  two.onkeypress = function(e){     input2value = e.target.value;     lastchanged = 2;     console.log("lastchanged ", lastchanged, " value ", input2value);     }; }; 

you can update value of input element updating value property


Comments

Popular posts from this blog

Why does Go error when trying to marshal this JSON? -

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

python - Pygame. TypeError: 'pygame.Surface' object is not callable -