开发者

"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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜