先看代码,后面详细解释:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script type="text/javascript" src="js/jquery-1.9.1.js" ></script>
<script>
$(function(){
//选择type类型进行更改
$("input[type=text]").css("background-color","aquamarine"); //选择name属性以z开头的
$("input[name^=z]").css("background-color","aquamarine"); //选择name属性以e结尾
$("input[name$=e]").css("background-color","aquamarine"); //选择name属性中有p
$("input[name*=p]").css("background-color","aquamarine"); //选择复合器,同时符合多种条件多种
$("input[type=text][name*=n]").css("background-color","aquamarine"); }) </script>
</head>
<body>
<center>
<h3>注册页面</h3>
<hr />
<form action="" method="get">
<table border="1px">
<tr height="35px">
<td width="150px">用户名:</td>
<td width="400px">
<input type="text" name="zuname" id="uname" value="" alt="用户名" οnblur="checkName()"/>
<span id="uname_span">*用户名必须是3-5位的汉字</span>
</td>
</tr>
<tr height="35px">
<td>密码:</td>
<td>
<input type="password" name="zpwd" id="pwd" value="" alt="密码" οnblur="checkPwd()"/>
<span id="pwd_span"></span> </td>
</tr>
<tr height="35px">
<td>手机号:</td>
<td>
<input type="text" name="zphone" id="phone" value="" alt="手机号" />
<span id="phone_span"></span>
</td>
</tr>
<tr height="35px">
<td>邮箱:</td>
<td>
<input type="text" name="email" id="email" value="" alt="邮箱" οnblur="checkEmail()" />
<span id="email_span"></span>
</td>
</tr>
<tr height="35px">
<td>颜色:</td>
<td>
<input type="color" name="scolor" id="" />
</td>
</tr>
<tr height="35px">
<td>爱好:</td>
<td>
<input type="checkbox" name="fav" id="" value="1" />唱歌
<input type="checkbox" name="fav" id="" value="2" />睡觉
<input type="checkbox" name="fav" id="" value="3" />LOL<br />
<input type="checkbox" name="fav" id="" value="4" />旅游
<input type="checkbox" name="fav" id="" value="5" />高尔夫
<input type="checkbox" name="fav" id="" value="6" />篮球 </td>
</tr>
<tr height="35px">
<td>籍贯:</td>
<td>
<select name="adress" id="sel" οnchange="checkAdress()">
<option value="0">--请选择--</option>
<option value="1">河南</option>
<option value="2">湖南</option>
<option value="3">海南</option>
<option value="4">云南</option>
</select> <span id="sel_span"></span>
</td>
</tr> <tr height="35px">
<td>验证码</td>
<td>
<input type="number" name="" id="yzm" value="" οnblur="checkYZM()"/>
<span id="yzm_span"></span>
<span id="yzm2_span"></span>
</td>
</tr> <tr height="35px">
<td>个人介绍:</td>
<td>
<textarea name="intro" rows="8" cols="30"></textarea>
</td>
</tr> <tr height="35px">
<td colspan="2" align="center">
<input type="checkbox" name="" id="check" value="" οnclick="checkAgree()">是否同一本公司协议
</td>
</tr>
<tr height="35px">
<td colspan="2" align="center">
<input type="submit" id="sub" value="注册" disabled="true"/>
</td>
</tr>
</table>
</form>
</center> </body>
</html>

选择type属性是text的标签:(类似于 $(":text"))

$("input[type=text]").css("background-color","aquamarine");

选择name属性以z开头的:(开头符号 ^)

$("input[name^=z]").css("background-color","aquamarine");

选择name属性以e结尾:(结尾符号 $)

$("input[name$=e]").css("background-color","aquamarine");

选择name属性中有p:(包含,含有 符号:*)

$("input[name*=p]").css("background-color","aquamarine");

选择复合器,同时符合多种条件多种:

$("input[type=text][name*=n]").css("background-color","aquamarine");
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script type="text/javascript" src="js/jquery-1.9.1.js" ></script>
<script>
$(function(){ //获取form表单的所有表单项
var inp=$(":input").length;
//alert(inp); //获取input标签中type属性是text
$(":text").css("background-color","darkblue");
//等同于:
$("input[type=text]").css("background-color","darkblue"); //获取input标签中checked属性
var val=$("input:checked");
//alert(val.val()); //获取input标签中属性disabled
var dd=$("input:disabled");
alert(dd.val()); //获取select中有selected属性。
var val=$("select option:selected");
//alert(val.val()); }) </script>
</head>
<body>
<center>
<h3>注册页面</h3>
<hr />
<form action="" method="get">
<table border="1px">
<tr height="35px">
<td width="150px">用户名:</td>
<td width="400px">
<input type="text" name="zuname" id="uname" value="" alt="用户名" οnblur="checkName()"/>
<span id="uname_span">*用户名必须是3-5位的汉字</span>
</td>
</tr>
<tr height="35px">
<td>密码:</td>
<td>
<input type="password" name="zpwd" id="pwd" value="" alt="密码" οnblur="checkPwd()"/>
<span id="pwd_span"></span> </td>
</tr>
<tr height="35px">
<td>手机号:</td>
<td>
<input type="text" name="zphone" id="phone" value="" alt="手机号" />
<span id="phone_span"></span>
</td>
</tr>
<tr height="35px">
<td>邮箱:</td>
<td>
<input type="text" name="email" id="email" value="" alt="邮箱" οnblur="checkEmail()" />
<span id="email_span"></span>
</td>
</tr>
<tr height="35px">
<td>颜色:</td>
<td>
<input type="color" name="scolor" id="" />
</td>
</tr>
<tr height="35px">
<td>爱好:</td>
<td>
<input type="checkbox" name="fav" id="" value="0"/>唱歌
<input type="checkbox" name="fav" id="" value="1" checked="checked"/>睡觉
<input type="checkbox" name="fav" id="" value="2"/>LOL
<input type="checkbox" name="fav" id="" value="3"/>旅游
<input type="checkbox" name="fav" id="" value="4"/>高尔夫
<input type="checkbox" name="fav" id="" value="5"/>篮球 </td>
</tr>
<tr height="35px">
<td>籍贯:</td>
<td>
<select name="adress" id="sel" οnchange="checkAdress()">
<option value="0">--请选择--</option>
<option >河南</option>
<option >湖南</option>
<option selected="selected">海南</option>
<option >云南</option>
</select> <span id="sel_span"></span>
</td>
</tr> <tr height="35px">
<td>验证码</td>
<td>
<input type="number" name="" id="yzm" value="" οnblur="checkYZM()"/>
<span id="yzm_span"></span>
<span id="yzm2_span"></span>
</td>
</tr> <tr height="35px">
<td>个人介绍:</td>
<td>
<textarea name="intro" rows="8" cols="30"></textarea>
</td>
</tr> <tr height="35px">
<td colspan="2" align="center">
<input type="checkbox" name="" id="check" value="" οnclick="checkAgree()">是否同一本公司协议
</td>
</tr>
<tr height="35px">
<td colspan="2" align="center">
<input type="submit" id="sub" value="注册" disabled="true"/>
</td>
</tr>
</table>
</form>
</center> </body>
</html>

获取form表单的所有表单项和   $("input")   进行区别开, $("input") 表示获取表单元素是input的。

$(":input")

获取input标签中type属性是text:

$(":text").css("background-color","darkblue");

获取input标签中checked属性:

$("input:checked");

获取input标签中属性disabled:

$("input:disabled");

获取select中有selected属性:

$("select option:selected");

jQuery中的属性选择器的更多相关文章

  1. js进阶 10-6 jquery中的属性选择器有哪些

    js进阶 10-6 jquery中的属性选择器有哪些 一.总结 一句话总结: 1.第一遍能学会么? 一遍是肯定学不会的,要多学几遍,所以想着怎么加快速度,减少学习的遍数 2.属性选择器是干嘛的? 选择 ...

  2. jQuery入门(1)jQuery中万能的选择器

    jQuery入门(1)jQuery中万能的选择器 jQuery入门(2)使用jQuery操作元素的属性与样式 jQuery入门(3)事件与事件对象 jQuery入门(4)jQuery中的Ajax()应 ...

  3. jquery笔记之属性选择器 查找以某种条件开头的页面元素

    jquery笔记之属性选择器 查找以某种条件开头的页面元素 转载:http://www.blogbus.com/amyqiong-logs/78340326.html $("div[id]& ...

  4. js进阶 10-5 jquery中的层级选择器有哪些

    js进阶 10-5 jquery中的层级选择器有哪些 一.总结 一句话总结: 1.jquery中的层级选择器有哪些? 四种,后代,子代,兄弟,相邻兄弟 2.如何区别jquery中的层级选择器? 记住这 ...

  5. jquery中的属性和css

    jQuery中的属性用于获取或设置元素的属性 1.attr(),获取或设置所有相匹配的元素的属性值:removeAttr("attr"),移除所有相匹配的元素的属性 //html ...

  6. jQuery中的:input选择器

    jQuery中的:input选择器 jQuery中的:input选择器包含input, textarea, select 和 button这些标签. <!DOCTYPE html> < ...

  7. js进阶 11-3 jquery中css属性如何操作

    js进阶 11-3  jquery中css属性如何操作 一.总结 一句话总结:通过css()方法 1.attr和css是有交叉的,比如width,两者中都可以设置,那么他们的区别是什么? 其实通俗一点 ...

  8. jQuery中的属性过滤选择器(四、五):[attribute] 、[attribute=value]、[attribute!=value] 、[attribute^=value] 等

    <!DOCTYPE html> <html> <head> <title>属性过滤选择器</title> <meta http-equ ...

  9. jQuery选择器之属性选择器Demo

    测试代码: 06-属性选择器.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" &quo ...

随机推荐

  1. sublime3中运行python文件

    sublime3中运行python文件 tools->build system->new build stystem 粘贴下面代码{"cmd":["pytho ...

  2. Python 基础 内置函数 迭代器与生成器

    今天就来介绍一下内置函数和迭代器 .生成器相关的知识 一.内置函数:就是Python为我们提供的直接可以使用的函数. 简单介绍几个自己认为比较重要的 1.#1.eval函数:(可以把文件中每行中的数据 ...

  3. W与V模型的联系与区别

      很多小白一定要注意:        看准那个是开发的工作哪个是测试的工作,不要弄混了!!!   软件测试的V模型 以“编码”为黄金分割线,将整个过程分为开发和测试,并且开发和测试之间是串行的关系 ...

  4. Arduino 配置 ESP8266环境

    Arduino 配置 ESP8266环境 将 http://arduino.esp8266.com/stable/package_esp8266com_index.json 添加到 [附加开发板管理器 ...

  5. linux内核的tiny rcu, tree rcu

    kernel中有两个rcu的实现,一个是tiny rcu,另一个是tree rcu.这两种rcu的前身都是classic rcu.如果要阅读classic rcu的实现代码,必须找kernel 2.6 ...

  6. gcc悄无声色将静态函数内联了

    说到内联,可能你还停在十几年前甚至二十多年前的C++教典,c++有内联关键字inline,甚至还用来与c做区分.c99开始c引入inline,gcc比c99早实现对inline支持,vc中c没有关键字 ...

  7. Missing radix parameter 错误的解决办法

    下载了Mint-Ui的example,使用npm run dev时发现如下报错: ERROR in ./packages/loadmore/src/loadmore.vue ✘ http://esli ...

  8. 记一个vue-resource请求的低级错误

    对于初学的小菜鸡,经常会犯一些低级错误. 现在记录一下我在使用vue-resource发送post请求时的一个低级错误: window.BaseURL = '127.0.0.1:8888'; 8888 ...

  9. Java基础知识总结之垃圾回收机制

    垃圾回收机制 Java垃圾回收机制是Java语言的重要功能之一.当程序创建对象,数组等引用类型对象时,系统会自动在内存区为之分配一块内存,对象就保存在这块内存区内,当这块内存不再被任何变量引用时,这块 ...

  10. 20191017-6alpha week 2/2 Scrum立会报告+燃尽图 05

    此作业要求参见https://edu.cnblogs.com/campus/nenu/2019fall/homework/9802 一.小组情况 队名:扛把子 组长:迟俊文 组员:宋晓丽 梁梦瑶 韩昊 ...