在
jquery
中
,你能够通过逗号,来分隔字符选择多个选择。
$(.
class
1, .
class
2, #id1)在以上的例子
中
,将会选择含有类名为
class
1,和
class
2及id为1的所有元素。
Jquery
实例:
在以下的例子
中
,有类名为p1和类名为p2 和id 为
div
3 的所有元素将会动态的添加
一个
红色的边框。
<title>select mutiple elements example</title>
[removed][removed]
$( "#id" )
id选择器也是基本的选择器,
jQuery
内部使用JavaScript函数document.getElementById()来处理ID的
获取
。原生语法的支持总是非常高效的,所以在操作DOM的
获取
上,如果能采用id的话尽然考虑用这个选择器。
id是唯一的,每个id值在
一个
页面
中
只...
如图,如果像选择类名为
class
=exerciseInfo
中
的第
一个
和
最后
一个
div
,做法如下:
选择第
一个
类名: .exerciseInfo: nth-of-type(1) { ... };
选择
最后
一个
类名: .exerciseInfo: last-child { ... };
选择其
中
一个
指定的类名:.exerciseInfo: nth-of-type(x) { ... }...
var o
Div
= document.getElementById("
div
111");
var a
Div
= o
Div
.getElementsByTagName("
div
");
alert(a
Div
.length);
jQuery
:
var o
Div
= $("#
div
111 .
div
class
");
alert(o
Div
.leng
$(".cartProList span.proPrice").each(function(){
// let this = $(this);
console.log($(this).html());
// 1.选择样式
$("p.chooseIcon").on("click","i",function() {
// body...
<
div
class
="app_info_xm">
<p
class
="bg_gr">上午8:00~12:30</p>
<p
class
="bg_og">上午8:00~12:30</p>
<p>下午12:30~17:30</p...
IDEA 导入Gradle项目报:Expiring Daemon because JVM heap space is exhausted 或 GC overhead limit exceeded
List<T>序列化为byte[]
开发环境下vue项目解决跨域问题(亲测可用)