javascript - Trigger action on Label change -
i'm doing website plugin appending block of code on existing web page, monitors content change of web element on existing page , trigger further actions on change.
as plugin don't want modify code block of original page, want monitored element , register kind of "change event" on element code block. example
<html> ... <body> ... <label id="idlable">some text</label> ... <!-- here begin code block --> <script> var label = document.getelementbyid("idlabel") label.addonchange(function (oldvalue, newvalue) { //do }); </script> <!-- here end code block --> </body> </html>
i googled long time, didn't find solution. there possible that?
my thanks, hai
there no native function/option in js. can monitor changes using setinterval function here sample code :
var oldtext=document.getelementbyid("idlabel").data; var tmr = window.setinterval(function(){ if(document.getelementbyid("idlabel").data != oldtext ) { //your code goes here window.clearinterval(tmr); } },1000);
Comments
Post a Comment