| 语法 | 描述 |
|---|---|
| $(this) | 当前 HTML 元素 |
| $("p") | 所有 <p> 元素 |
| $("p.intro") | 所有 class="intro" 的 <p> 元素 |
| $(".intro") | 所有 class="intro" 的元素 |
| $("#intro") | id="intro" 的元素 |
| $("ul li:first") | 每个 <ul> 的第一个 <li> 元素 |
| $("[href$='.jpg']") | 所有带有以 ".jpg" 结尾的属性值的 href 属性 |
| $("div#intro .head") | id="intro" 的 <div> 元素中的所有 class="head" 的元素 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>属性选择器</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<style type="text/css">
.yang{ border-collapse: collapse; width:500px;height:30px;border:1px solid red;"}
</style>
<script type="text/javascript" src="jquery-1.7.1.min.js"></script>
<script type="text/javascript">
/*
[attribute] :匹配具有指定属性的元素
[attribute=value] :匹配属性为指定值的元素
[attribute!=value] :匹配属性值不等于指定值的元素
[attribute^=value] :匹配属性值以指定值开始的元素
[attribute$=value] :匹配属性值以指定值结束的元素
[attribute*=value] :匹配属性值中包含指定值的元素
[selector1][selector2][selectorN] :同时指定多个匹配条件
*/
window.onload=function(){
$(‘#btnOk‘).click(function(){
//匹配具有color属性的font并把内容改为jquery
$(‘font[color]‘).html(‘jquery‘);
});
};
</script>
</head>
<body>
<font>字体1</font>
<hr />
<font color="#336699">字体2</font>
<hr />
<font color="#667788">字体3</font>
<hr />
<font color="#338899">字体4</font>
<hr />
<font color="#FFAA99">字体5</font>
<hr />
<hr/>
<input type="button" id=‘btnOk‘ value=‘确定‘ />
</body>
</html>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有