您好,欢迎来到哈瑞养生。
搜索
您的当前位置:首页JQuery中几个类选择器的简单使用介绍_jquery

JQuery中几个类选择器的简单使用介绍_jquery

来源:哈瑞养生


代码如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TestClassSelector.aspx.cs" Inherits="WebApplication1.TestClassSelector" %>












function btn_Click() {
alert($(".first_div").text());
alert($(".first_div.first_span").text());
}


代码如下:
$(".first_div, .first_span")

将包含有.first_div 或者 .first_span" 的对象都取到。 这里取到 4 个 对象。
此处的Html对应
代码如下:

This is the first div



This is the first span



This is the first span + eric sun class.


代码如下:
$(".first_div .first_span")

将以 .first_div 为类的控件 下的 以 .first_span 为类 的对象取到(类与类之间带有空格 逐层取)。 这里只取到 1 个。
对应的 className="first_span" 此处的Html对应
代码如下:


This is the first span



代码如下:
$(".first_span.eric_sun_class")

将包含有.first_span 并且同时包含有 .eric_sun_class 类的 对象取到(类与类之间没有空格 类似于 ‘与' 操作)。 这里只取到1个。
对应的 className="first_span eric_sun_class" 此处的Html 对应
代码如下:

This is the first span + eric sun class.

Copyright © 2019- harx.cn 版权所有

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务