六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 32|回复: 0

jQuery入门[2]-选择器

[复制链接]

升级  85.33%

142

主题

142

主题

142

主题

举人

Rank: 3Rank: 3

积分
456
 楼主| 发表于 2013-1-29 07:42:34 | 显示全部楼层 |阅读模式
jQuery入门[2]-选择器

<div class="clear" /><div class="postBody">jQuery入门[1]-构造函数
jQuery入门[2]-选择器
jQuery入门[3]-事件
jQuery入门[4]-链式代码
jQuery入门[5]-AJAX
jQuery入门[6]-动画

jQuery之所以令人爱不释手,在于其强大的选择器表达式令DOM操作优雅而艺术。
jQuery的选择符支持id,tagName,css1-3 expressions,XPath,参见:http://docs.jquery.com/Selectors
DEMO:
<div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px;"><!----><!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>
    
<title>Selector</title>
    
<script src="../scripts/jquery-1.2.3.intellisense.js" type="text/javascript"></script>
</head>
<body>
    
<input value="1" /> + 
    
<input value="2" />
    
<input type="button" value="=" />
    
<label> </label>
    
<script type="text/javascript">
        $(
"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')
            .css(
'borderBottom','solid 1px navy')
            .css({
'width':'30px'});
    
</script>
</body>
</html>
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表