动态监测input标签

oninput="OnInput (event)" onpropertychange="OnPropChanged (event)"

 

<script type="text/javascript">
    // Firefox, Google Chrome, Opera, Safari, Internet Explorer from version 9
        function OnInput (event) {
         //  alert ("The new content: " + event.target.value);
            var sum=event.target.value;
            document.getElementById("avenum").innerHTML=(sum*4/96).toFixed(2);
        }
      
    // Internet Explorer
        function OnPropChanged (event) {
            if (event.propertyName.toLowerCase () == "value") {
                //alert ("The new content: " + event.srcElement.value);
                var sum=event.srcElement.value;
                document.getElementById("avenum").innerHTML=(sum*4/96).toFixed(2);
               
            }
        }
     // 改变默认值ya
     function pre (event) {
         event.style.color = "black";
         event.value="";
        }
    </script>

posted on 2016-06-18 21:53  静以修身!  阅读(539)  评论(0编辑  收藏  举报

导航