博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
JQuery 中简单的几个 类选择器 使用方法
阅读量:7210 次
发布时间:2019-06-29

本文共 1384 字,大约阅读时间需要 4 分钟。

前台代码:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TestClassSelector.aspx.cs" Inherits="WebApplication1.TestClassSelector" %>                
This is the first div
This is the second div
This is the first span
This is the first span + eric sun class.
This is the eric sun class.

 

$(".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.  

更多关于选择器的知识请看:

 

转载地址:http://gprum.baihongyu.com/

你可能感兴趣的文章
用正则表达式提取字符串中的字符(包含数字)
查看>>
Ubuntu 12.04 LTS(64 bit) + RTL8188CU无线网卡驱动
查看>>
Asp.net MVC中提交集合对象,实现Model绑定
查看>>
谁说码农不懂浪漫?(js写的'老婆生日快乐'特效)
查看>>
构建ASP.NET MVC4+EF5+EasyUI+Unity2.x注入的后台管理系统(16)-权限管理系统-漂亮的验证码...
查看>>
学习VI的强文,新工作需要呀
查看>>
使用html和css的一些经验
查看>>
GNU的ar,ranlib和nm
查看>>
《Linux内核设计与实现》读书笔记(十九)- 可移植性
查看>>
都是假期惹的祸,该如何安慰自己?
查看>>
从零开始学JavaScript二(基本概念)
查看>>
Android AlarmManager(全局定时器/闹钟)指定时长或以周期形式执行某项操作
查看>>
js中的var
查看>>
年终知识分享——移动应用开发
查看>>
Centos 5.5 安装Mysql5.5过程
查看>>
网络爬虫基本原理(二)
查看>>
AndroidUI组件之ListView小技巧
查看>>
使用ThinkPHP框架高速开发站点(多图)
查看>>
解决iframe缓存
查看>>
mysql事物
查看>>