码迷,mamicode.com
首页 > Web开发 > 详细

利用jQuery选择器快速匹配文档中的按钮,并为该按钮绑定事件处理函数

时间:2017-05-12 23:14:11      阅读:297      评论:0      收藏:0      [点我收藏+]

标签:css   选择   ott   span   his   .text   w3c   asc   img   

技术分享
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="jQuery/版本号自己选"></script>
<script type="text/javascript">
$(function(){
    $(‘input[type="button"]‘).click(function(){
        var i = 0;
        $(‘input[type="text"]‘).each(function(){
            i += parseInt($(this).val());
        });
        $("label").text(i);
    });
    $(‘input:lt(2)‘)
        .add("label")
        .css({
            ‘border‘:‘none‘,
            ‘textAlign‘:‘center‘,
            ‘borderBottom‘:‘solid 1px navy‘,
            ‘width‘:‘30px‘
        });
});
</script>
<title>上机练习</title>
</head>

<body>
<input type="text" value="" />+
<input type="text" value="" />
<input type="button" value="=" />
<label></label>
</body>
</html>
View Code

技术分享

利用jQuery选择器快速匹配文档中的按钮,并为该按钮绑定事件处理函数

标签:css   选择   ott   span   his   .text   w3c   asc   img   

原文地址:http://www.cnblogs.com/harrell/p/6847483.html

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