Is it possible to use onchange
event in a <div>
?
Because my <div>
changes its text inside.
Can I do something like this?
<div id="name" onchange="calculateTotal();"></div>
Is it possible to use onchange
event in a <div>
?
Because my <div>
changes its text inside.
Can I do something like this?
<div id="name" onchange="calculateTotal();"></div>
Since you say you're using AJAX, why not execute the function when you update the text. I'm not sure if you use any library, but in case it's jQuery just do:
$.ajax({ ...,
success: function() {
... other things ...
... setting div text ...
calculateTotal();
}
});
No; the onchange
attribute is only applicable to form field elements (input
, select
, textarea
, etc).
As you are changing the text yourself, just call calculateTotal
when the AJAX call completes and the text has been placed in the element.
Example (using jQuery):
$('#name').load('GetFragment.php', calculateTotal);
Onchange is called when user changed input value. So answer is yes, but it will have no effect. I assume you change content programmatically, so add simple code which will call this function