I have the following code snippet that is used to simulate a text field:
<label for="alertCmpVal">ALERT VALUE:</label> <span class="center textBox displayField highlight" id="alertCmpVal" contenteditable> <?php print $alert_val;?> </span>
I need to know when the content changes, for example. I click on it and change it from 0 to 1.
I tried:
$(document).ready(function() { $(document.body).on('change','#alertCmpVal',function() { alert("boo"); $('#alertCmpVal').removeClass('highlight'); }) }
but this does not seem to work.
(nb $(document.body ) is used because on my main page the start field is loaded dynamically)
I assume that this is a βchangeβ that he does not like, but cannot understand what to replace. (jQuery / HTML5 is excellent as it is used only internally).
I saw a few examples, but they usually seem to be more complex scenarios that require several functions to detect changes when some other events happen, but I believe there should be a simpler solution similar to the on change method.
jquery onchange
Iggt
source share