"onchange" event not firing in Safari family browsers(for a fieldset)
I know that I should use its alternative "onclick" for "checkboxes", to ove开发者_C百科rcome this problem in "Safari" and "Chrome". But what should I do if I want to use an "onchange" event for a "fieldset" (a group of checkboxes)?
It seems that assigning "onchange" event after page load using "javascript" , works! Here is an example:
<script type="text/javascript">
window.onload = function() {
var fieldsets = document.getElementsByTagName("fieldset");
for( i = 0 ; i < fieldsets.length ; i++ ) {
fieldsets[i].onchange = function() {
Validate(); // Calling sample function
}
}
}
function Validate() {
// Sample function content
}
</script>
精彩评论