您的位置:首页 > Web前端 > JQuery

JQuery - * 选择器

2014-01-20 00:00 197 查看
1. #('*') 选择所有元素。

2. #('div > *')选择所有的div元素

<html>
<head>
<title>jQuery universal example</title>

<script type="text/javascript" src="jquery-1.9.1.js"></script>

<style type="text/css">
div{
padding:8px;
}
</style>
</head>

<body>

<h1>jQuery universal example</h1>

<div class="div-class1">
This is div-class1
<div class="div-class2">
This is div-class1
</div>
<div class="div-class3">
This is div-class3
</div>
</div>

<br/><br/>
<button>*</button>
<button>div > *</button>
<button id="refresh">Refresh</button>

<script type="text/javascript">
$("button").click(function () {
var str = $(this).text();
$(str).css("border", "1px solid #ff0000");
});

$('#refresh').click(function() {
location.reload();
});

</script>

</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: