Home > Web Front-end > JS Tutorial > The use of jQuery Selectors (9. Form object attributes)_jquery

The use of jQuery Selectors (9. Form object attributes)_jquery

WBOY
Release: 2016-05-16 18:39:29
Original
1367 people have browsed it

This series of articles is divided into nine articles: basic article, hierarchical article, simple article, content article, visibility article, attributes article, sub-element article, form article, and form object properties article.
This article explains: the usage of :enabled, :disabled, :checked, :selected.
If you have any suggestions or comments about this series of articles, please send them to the email: sjzlgt@qq.com
Since this is the first time to write a technical series of articles, it is inevitable that there will be errors or code bugs. You are welcome to point them out and thank you!
After running, you need to refresh and load jquery

2. :disabled usage Definition: Match all unavailable elements Return value: Array Example: Change the background color of all unavailable input elements in the DIV with ID "div_b1" to red Code: $("#div_b1 input:disabled").css("background-color","red"); //Clicking button two will execute this code
DIV ID="div_b1" span ID="span_b1"
3. :checked用法 定义:匹配所有选中的被选中元素(复选框、单选框等,不包括select中的option) 返回值:Array 实例:将ID为"div_c1"的DIV中所有包含选中状态复选框的元素背景色改为红色 代码: $("#div_c1 :has(input[type='checkbox']:checked)").css("background-color","red"); //点击按钮三将执行这句代码
DIV ID="div_c1" span ID="span_c1"
DIV id="div_c1_1"
DIV id="div_c1_2"
DIV id="div_c1_3"
DIV id="div_c1_4"
注意::has(selector)用法参见内容篇&可见性篇第3点, [type='checkbox']用法参见属性篇第2点。
4. :selected用法 定义:匹配所有选中的option元素 返回值:Array 实例:将ID为"div_d1"的DIV中所有select元素中选中的option元素的text值写入div_d1_1中 代码: var SelectedText=$("#div_d1 :selected"); //点击按钮四将执行这句代码
DIV ID="div_d1" span ID="span_d1"    
DIV id="div_d1_1"
注意:append(content)指向某元素内部追加content,在以后的章节中会有讲解,敬请关注。

[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]

文件打包下载http://xiazai.jb51.net/200912/yuanma/jQuery-Selectors-9-bynet.rar
Related labels:
source:php.cn
Previous article:JavaScript string and array conversion functions [without split and join]_javascript skills Next article:Use jquery ajax to get the code for website Alexa ranking_jquery
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Latest Issues
Related Topics
More>
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template