码迷,mamicode.com
首页 > 其他好文 > 详细

动态监测input标签

时间:2016-06-18 22:32:33      阅读:194      评论:0      收藏:0      [点我收藏+]

标签:

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>

动态监测input标签

标签:

原文地址:http://www.cnblogs.com/lengzhijun/p/5596977.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!