JQuery 中简单的几个 类选择器 使用方法
2013-03-14 08:39
597 查看
前台代码:
将包含有.first_div 或者 .first_span" 的对象都取到。 这里取到 4 个 对象。
此处的Html对应
将以 .first_div 为类的控件 下的 以 .first_span 为类 的对象取到(类与类之间带有空格 逐层取)。 这里只取到 1 个。
对应的 className="first_span" 此处的Html对应
将包含有.first_span 并且同时包含有 .eric_sun_class 类的 对象取到(类与类之间没有空格 类似于 ‘与’ 操作)。 这里只取到1个。
对应的 className="first_span eric_sun_class" 此处的Html 对应
更多关于选择器的知识请看:
http://developer.51cto.com/art/201009/226852.htm
http://www.w3.org/TR/css3-selectors/
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TestClassSelector.aspx.cs" Inherits="WebApplication1.TestClassSelector" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script src="Scripts/jquery-1.9.0.min.js"></script> <style type="text/css"> .first_div { background-color:red; } .second_div { background-color:green; } .first_span { width:500px; height:100px; } .eric_sun_class { font-family:Arial; font-size:18px; } </style> </head> <body> <form id="form1" runat="server"> <div> <div class="first_div"> This is the first div </div> <div class="second_div"> This is the second div </div> <div class="first_div"> <span class="first_span"> This is the first span </span> </div> <span class="first_span eric_sun_class"> This is the first span + eric sun class. </span> <br /> <span class="eric_sun_class"> This is the eric sun class. </span> <br /> <input type="button" value="Test" onclick="btn_Click();" /> </div> </form> </body> </html> <script type="text/javascript"> function btn_Click() { alert($(".first_div").text()); alert($(".first_div.first_span").text()); } </script>
$(".first_div, .first_span")
将包含有.first_div 或者 .first_span" 的对象都取到。 这里取到 4 个 对象。
此处的Html对应
<div class="first_div"> This is the first div </div> <div class="first_div"> <span class="first_span"> This is the first span </span> </div> <span class="first_span eric_sun_class"> This is the first span + eric sun class. </span>
$(".first_div .first_span")
将以 .first_div 为类的控件 下的 以 .first_span 为类 的对象取到(类与类之间带有空格 逐层取)。 这里只取到 1 个。
对应的 className="first_span" 此处的Html对应
<div class="first_div"> <span class="first_span"> This is the first span </span> </div>
$(".first_span.eric_sun_class")
将包含有.first_span 并且同时包含有 .eric_sun_class 类的 对象取到(类与类之间没有空格 类似于 ‘与’ 操作)。 这里只取到1个。
对应的 className="first_span eric_sun_class" 此处的Html 对应
<span class="first_span eric_sun_class"> This is the first span + eric sun class. </span>
更多关于选择器的知识请看:
http://developer.51cto.com/art/201009/226852.htm
http://www.w3.org/TR/css3-selectors/
相关文章推荐
- 几个简单的jQuery使用方法
- 使用JS/Jquery获得父窗口的几个方法(笔记)
- obstart() 几个函数的简单使用方法
- jQuery NProgress.js加载进度插件的简单使用方法
- objc_runtime使用方法的几个简单例子
- jQuery插件Tmpl的简单使用方法
- Visual Studio 2017中使用正则修改部分内容 如何使用ILAsm与ILDasm修改.Net exe(dll)文件 C#学习-图解教程(1):格式化数字字符串 小程序开发之图片转Base64(C#、.Net) jquery遍历table为每一个单元格取值及赋值 。net加密解密相关方法 .net关于坐标之间一些简单操作
- jQuery使用$.each遍历json数组的简单实现方法
- jQuery表格插件ParamQuery简单使用方法示例
- 使用jQuery在对象中缓存选择器的简单方法
- 使用JS/Jquery获得父窗口的几个方法(笔记)
- jQuery插件Tmpl的简单使用方法
- jQuery使用$.each遍历json数组的简单实现方法
- JQuery 中几个类选择器的简单使用介绍
- 使用jQuery在对象中缓存选择器的简单方法
- objc_runtime使用方法的几个简单例子(转)
- Jquery的几个方法使用.
- 获取命令使用的方法和几个简单的操作命令
- jquery中checkbox使用方法简单实例演示
- jquery validate 使用方法简单记要