Jquery选择器易混淆处(1),jquery选择器混淆处
文章作者:网络世界 上传时间:2019-11-17
Jquery选择器易混淆处(1),jquery选择器混淆处
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>zran's test </title>
<style type="text/css">
html{height:100%}
body{height:100%;margin:0px;padding:0px}
#container{height:100%}
</style>
</head>
<body>
<div id="container" class="a b">
test
</div>
</body>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
alert($("div .c").html()); //test
alert($("div span").html()); //test
alert($("div .a").html()); //undefined
alert($("div.a").html()); //test
alert($(".a.b").html()); //test
alert($(".a b").html()); //undefined
alert($(".a .b").html()); //undefined
alert($(".a.c").html()); //undefined
alert($(".a .c").html()); //test
</script>
</html>
小结:之前对jquery的选择器均不甚熟悉,今天多次试验之后,困惑的地方有一些解答。
引号中“空格”隔开表示选择前一元素内部元素,没有空格隔开表示所有内容用于选择同一(类)元素。
例如:$(".a.b")为选择class="a b"的元素,
$(".a .b")为选择class="a"元素内class="b"的元素。
http://www.bkjia.com/jQuery/1309728.htmlwww.bkjia.comtruehttp://www.bkjia.com/jQuery/1309728.htmlTechArticleJquery选择器易混淆处(1),jquery选择器混淆处 ! DOCTYPE html html head meta name ="viewport" content ="initial-scale=1.0, user-scalable=no" / meta http-equiv ="Content-...
本文由金沙国际app发布于网络世界,转载请注明出处:Jquery选择器易混淆处(1),jquery选择器混淆处
关键词:
下一篇:没有了