jQuery event listener-Continuous or Live
I have my input elements and their change events to handle some display.
After loading page, When input values are changed through some other jquery functions...I do not have a way to know the values are changed. Please note that I can not change or do anything with that other jquery function which changes my input values. It is not in my control.
Can we have something in jQuery API which continuously keep checking or listening any changes happened to the html elements through external/internal uncontrollable events!
I have given Example below.
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("span").on("click", function() {
<-- I cannot make any changes in this event!
var chose = $(".chose").val();
if(chose == "a") {
$(".name").val("testME"); <--- I want to know of this event
//$("input").trigger("change"); <-- I cannot do this
}
});
$(".name").on("change", function(){
<--- Here
$("p").html($(this).val());
});
});
</script>
</head>
<body>
<input name="chose" value="" class="chose">
<span>click me</span>
<p>Display here</p>
<input name="test" value="" class="name">
</body>
</html>