帝王谷资源网 Design By www.wdxyy.com
一个针对jQuery属性选择器的小例子,增加对jQUery属性选择器的理解:
复制代码 代码如下:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<script src="/UploadFiles/2021-04-02/jquery-1.9.1.js"><style type="text/css">
a{
margin-right:20px;
}
ol{
position:relative;
width:600px;
margin-left:400px;
}
dt{
margin:10px;
height:100px;
background-color:#EAEAEA;
border:3px dotted orange;
}
.showMessage{
width:380px;
float:left;
background-color:#D8D8D8;
border:1px dotted red;
}
</style>
<script type="text/javascript">
$(document).ready(function(){
var subject = "";
var describe = "";
//name|="value"
$("#attri1").bind("click",function(){
var topValue=$("#attri1").offset().top;
subject = "Attribute Contains Prefix Selector [name|=\"value\"]";
describe = "Selects elements that have the specified attribute with a value either equal to a given string or starting with that string followed by a hyphen (-).";
$("a[hreflang|='en']").css("border","3px dotted green");
showMessage(subject,describe,topValue);
});
//name*="value"
$("#attri2").bind("click",function(){
var topValue=$("#attri2").offset().top;
subject = "Attribute Contains Selector [name*=\"value\"]";
describe = "Selects elements that have the specified attribute with a value containing the a given substring.";
$( "input[name*='man']" ).val( "has man in it!" );
showMessage(subject,describe,topValue);
});
//name~="value"
$("#attri3").bind("click",function(){
var topValue=$("#attri3").offset().top;
subject = "Attribute Contains Word Selector [name~=\"value\"]";
describe = "Selects elements that have the specified attribute with a value containing a given word, delimited by spaces.";
$( "input[name~='man']" ).val( "mr. man is in it!" );
showMessage(subject,describe,topValue);
});
//name$="value"
$("#attri4").bind("click",function(){
var topValue=$("#attri4").offset().top;
subject = "Attribute Ends With Selector [name$=\"value\"]";
describe = "Selects elements that have the specified attribute with a value ending exactly with a given string. The comparison is case sensitive.";
$( "input[name$='letter']" ).val( "a letter" );
showMessage(subject,describe,topValue);
});
//name="value"
$("#attri5").bind("click",function(){
var topValue=$("#attri5").offset().top;
subject = "Attribute Equals Selector [name=\"value\"]";
describe = "Selects elements that have the specified attribute with a value exactly equal to a certain value.";
$( "input[value='Hot Fuzz']" ).next().text( "Hot Fuzz" );
showMessage(subject,describe,topValue);
});
//name$="value"
$("#attri6").bind("click",function(){
var topValue=$("#attri6").offset().top;
subject = "Attribute Not Equal Selector [name!=\"value\"]";
describe = "Select elements that either don't have the specified attribute, or do have the specified attribute but not with a certain value.";
$( "input[name!='newsletter']" ).next().append( "<b>; not newsletter</b>" );
showMessage(subject,describe,topValue);
});
//name$="value"
$("#attri7").bind("click",function(){
var topValue=$("#attri7").offset().top;
subject = "Attribute Starts With Selector [name^=\"value\"]";
describe = "Selects elements that have the specified attribute with a value beginning exactly with a given string.";
$( "input[name^='news']" ).val( "news here!" );
showMessage(subject,describe,topValue);
});
//name$="value"
$("#attri8").bind("click",function(){
var topValue=$("#attri8").offset().top;
subject = "Has Attribute Selector [name]";
describe = "Selects elements that have the specified attribute, with any value.<br><b><font color=\"red\">you can click the div which have id element</font></b>";
$( "div[id]" ).one( "click", function() {
var idString = $( this ).text() + " = " + $( this ).attr( "id" );
$( this ).text( idString );
});
showMessage(subject,describe,topValue);
});
//name$="value"
$("#attri9").bind("click",function(){
var topValue=$("#attri9").offset().top;
subject = "Multiple Attribute Selector [name=\"value\"][name2=\"value2\"]";
describe = "Matches elements that match all of the specified attribute filters.";
$( "input[id][name$='man']" ).val( "only this one" );
showMessage(subject,describe,topValue);
});
});
function showMessage(subject,describe,topValue){
$("#showMessage").html("<font color=\"red\"><b>"+subject+"</b></font><br>"+describe)
.addClass("showMessage").css("margin-top",topValue).hide().show(1000);
}
</script>
</head>
<body>
<div id="showMessage"></div>
<ol>
<dt>
<input type="button" id="attri1" value="a[hreflang|='en']"/><br><br>
<a href="#" hreflang="en">en</a>
<a href="#" hreflang="en-">en-</a>
<a href="#" hreflang="english">english</a>
</dt>
<dt>
<input type="button" id="attri2" value="name*='man'"/><br><br>
<input name="man-news">
<input name="milkman"><br>
<input name="letterman2">
<input name="newmilk">
</dt>
<dt>
<input type="button" id="attri3" value="input[name~='man']"/><br><br>
<input name="man-news">
<input name="milk man"><br>
<input name="letterman2">
<input name="newmilk">
</dt>
<dt>
<input type="button" id="attri4" value="input[name$='letter']"/><br><br>
<input name="newsletter">
<input name="milkman"><br>
<input name="jobletter">
</dt>
<dt>
<input type="button" id="attri5" value="input[value='Hot Fuzz']"/><br><br>
<div>
<label>
<input type="radio" name="newsletter" value="Hot Fuzz">
<span>name?</span>
</label>
</div>
<div>
<label>
<input type="radio" name="newsletter" value="Cold Fusion">
<span>value?</span>
</label>
</div>
<div>
<label>
<input type="radio" name="newsletter" value="Evil Plans">
<span>value?</span>
</label>
</div>
</dt>
<dt>
<input type="button" id="attri6" value="input[name!='newsletter']"/><br><br>
<div>
<input type="radio" name="newsletter" value="Hot Fuzz">
<span>name is newsletter</span>
</div>
<div>
<input type="radio" value="Cold Fusion">
<span>no name</span>
</div>
<div>
<input type="radio" name="accept" value="Evil Plans">
<span>name is accept</span>
</div>
</dt>
<dt>
<input type="button" id="attri7" value="input[name^='news']"/><br><br>
<input name="newsletter">
<input name="milkman"><br>
<input name="newsboy">
</dt>
<dt>
<input type="button" id="attri8" value="div[id]"/><br>
<div>no id</div>
<div id="hey">with id</div>
<div id="there">has an id</div>
<div>nope</div>
</dt>
<dt>
<input type="button" id="attri9" value="input[id][name$='man']"/><br><br>
<input id="man-news" name="man-news">
<input name="milkman"><br>
<input id="letterman" name="new-letterman">
<input name="newmilk">
</dt>
<dt>
<input type="button" value="clearEffects" onclick="javaScript:window.location.reload();"/>
</dt>
</ol>
</body>
</html>
复制代码 代码如下:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<script src="/UploadFiles/2021-04-02/jquery-1.9.1.js"><style type="text/css">
a{
margin-right:20px;
}
ol{
position:relative;
width:600px;
margin-left:400px;
}
dt{
margin:10px;
height:100px;
background-color:#EAEAEA;
border:3px dotted orange;
}
.showMessage{
width:380px;
float:left;
background-color:#D8D8D8;
border:1px dotted red;
}
</style>
<script type="text/javascript">
$(document).ready(function(){
var subject = "";
var describe = "";
//name|="value"
$("#attri1").bind("click",function(){
var topValue=$("#attri1").offset().top;
subject = "Attribute Contains Prefix Selector [name|=\"value\"]";
describe = "Selects elements that have the specified attribute with a value either equal to a given string or starting with that string followed by a hyphen (-).";
$("a[hreflang|='en']").css("border","3px dotted green");
showMessage(subject,describe,topValue);
});
//name*="value"
$("#attri2").bind("click",function(){
var topValue=$("#attri2").offset().top;
subject = "Attribute Contains Selector [name*=\"value\"]";
describe = "Selects elements that have the specified attribute with a value containing the a given substring.";
$( "input[name*='man']" ).val( "has man in it!" );
showMessage(subject,describe,topValue);
});
//name~="value"
$("#attri3").bind("click",function(){
var topValue=$("#attri3").offset().top;
subject = "Attribute Contains Word Selector [name~=\"value\"]";
describe = "Selects elements that have the specified attribute with a value containing a given word, delimited by spaces.";
$( "input[name~='man']" ).val( "mr. man is in it!" );
showMessage(subject,describe,topValue);
});
//name$="value"
$("#attri4").bind("click",function(){
var topValue=$("#attri4").offset().top;
subject = "Attribute Ends With Selector [name$=\"value\"]";
describe = "Selects elements that have the specified attribute with a value ending exactly with a given string. The comparison is case sensitive.";
$( "input[name$='letter']" ).val( "a letter" );
showMessage(subject,describe,topValue);
});
//name="value"
$("#attri5").bind("click",function(){
var topValue=$("#attri5").offset().top;
subject = "Attribute Equals Selector [name=\"value\"]";
describe = "Selects elements that have the specified attribute with a value exactly equal to a certain value.";
$( "input[value='Hot Fuzz']" ).next().text( "Hot Fuzz" );
showMessage(subject,describe,topValue);
});
//name$="value"
$("#attri6").bind("click",function(){
var topValue=$("#attri6").offset().top;
subject = "Attribute Not Equal Selector [name!=\"value\"]";
describe = "Select elements that either don't have the specified attribute, or do have the specified attribute but not with a certain value.";
$( "input[name!='newsletter']" ).next().append( "<b>; not newsletter</b>" );
showMessage(subject,describe,topValue);
});
//name$="value"
$("#attri7").bind("click",function(){
var topValue=$("#attri7").offset().top;
subject = "Attribute Starts With Selector [name^=\"value\"]";
describe = "Selects elements that have the specified attribute with a value beginning exactly with a given string.";
$( "input[name^='news']" ).val( "news here!" );
showMessage(subject,describe,topValue);
});
//name$="value"
$("#attri8").bind("click",function(){
var topValue=$("#attri8").offset().top;
subject = "Has Attribute Selector [name]";
describe = "Selects elements that have the specified attribute, with any value.<br><b><font color=\"red\">you can click the div which have id element</font></b>";
$( "div[id]" ).one( "click", function() {
var idString = $( this ).text() + " = " + $( this ).attr( "id" );
$( this ).text( idString );
});
showMessage(subject,describe,topValue);
});
//name$="value"
$("#attri9").bind("click",function(){
var topValue=$("#attri9").offset().top;
subject = "Multiple Attribute Selector [name=\"value\"][name2=\"value2\"]";
describe = "Matches elements that match all of the specified attribute filters.";
$( "input[id][name$='man']" ).val( "only this one" );
showMessage(subject,describe,topValue);
});
});
function showMessage(subject,describe,topValue){
$("#showMessage").html("<font color=\"red\"><b>"+subject+"</b></font><br>"+describe)
.addClass("showMessage").css("margin-top",topValue).hide().show(1000);
}
</script>
</head>
<body>
<div id="showMessage"></div>
<ol>
<dt>
<input type="button" id="attri1" value="a[hreflang|='en']"/><br><br>
<a href="#" hreflang="en">en</a>
<a href="#" hreflang="en-">en-</a>
<a href="#" hreflang="english">english</a>
</dt>
<dt>
<input type="button" id="attri2" value="name*='man'"/><br><br>
<input name="man-news">
<input name="milkman"><br>
<input name="letterman2">
<input name="newmilk">
</dt>
<dt>
<input type="button" id="attri3" value="input[name~='man']"/><br><br>
<input name="man-news">
<input name="milk man"><br>
<input name="letterman2">
<input name="newmilk">
</dt>
<dt>
<input type="button" id="attri4" value="input[name$='letter']"/><br><br>
<input name="newsletter">
<input name="milkman"><br>
<input name="jobletter">
</dt>
<dt>
<input type="button" id="attri5" value="input[value='Hot Fuzz']"/><br><br>
<div>
<label>
<input type="radio" name="newsletter" value="Hot Fuzz">
<span>name?</span>
</label>
</div>
<div>
<label>
<input type="radio" name="newsletter" value="Cold Fusion">
<span>value?</span>
</label>
</div>
<div>
<label>
<input type="radio" name="newsletter" value="Evil Plans">
<span>value?</span>
</label>
</div>
</dt>
<dt>
<input type="button" id="attri6" value="input[name!='newsletter']"/><br><br>
<div>
<input type="radio" name="newsletter" value="Hot Fuzz">
<span>name is newsletter</span>
</div>
<div>
<input type="radio" value="Cold Fusion">
<span>no name</span>
</div>
<div>
<input type="radio" name="accept" value="Evil Plans">
<span>name is accept</span>
</div>
</dt>
<dt>
<input type="button" id="attri7" value="input[name^='news']"/><br><br>
<input name="newsletter">
<input name="milkman"><br>
<input name="newsboy">
</dt>
<dt>
<input type="button" id="attri8" value="div[id]"/><br>
<div>no id</div>
<div id="hey">with id</div>
<div id="there">has an id</div>
<div>nope</div>
</dt>
<dt>
<input type="button" id="attri9" value="input[id][name$='man']"/><br><br>
<input id="man-news" name="man-news">
<input name="milkman"><br>
<input id="letterman" name="new-letterman">
<input name="newmilk">
</dt>
<dt>
<input type="button" value="clearEffects" onclick="javaScript:window.location.reload();"/>
</dt>
</ol>
</body>
</html>
标签:
jQuery,属性选择器
帝王谷资源网 Design By www.wdxyy.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
帝王谷资源网 Design By www.wdxyy.com
暂无评论...
《魔兽世界》大逃杀!60人新游玩模式《强袭风暴》3月21日上线
暴雪近日发布了《魔兽世界》10.2.6 更新内容,新游玩模式《强袭风暴》即将于3月21 日在亚服上线,届时玩家将前往阿拉希高地展开一场 60 人大逃杀对战。
艾泽拉斯的冒险者已经征服了艾泽拉斯的大地及遥远的彼岸。他们在对抗世界上最致命的敌人时展现出过人的手腕,并且成功阻止终结宇宙等级的威胁。当他们在为即将于《魔兽世界》资料片《地心之战》中来袭的萨拉塔斯势力做战斗准备时,他们还需要在熟悉的阿拉希高地面对一个全新的敌人──那就是彼此。在《巨龙崛起》10.2.6 更新的《强袭风暴》中,玩家将会进入一个全新的海盗主题大逃杀式限时活动,其中包含极高的风险和史诗级的奖励。
《强袭风暴》不是普通的战场,作为一个独立于主游戏之外的活动,玩家可以用大逃杀的风格来体验《魔兽世界》,不分职业、不分装备(除了你在赛局中捡到的),光是技巧和战略的强弱之分就能决定出谁才是能坚持到最后的赢家。本次活动将会开放单人和双人模式,玩家在加入海盗主题的预赛大厅区域前,可以从强袭风暴角色画面新增好友。游玩游戏将可以累计名望轨迹,《巨龙崛起》和《魔兽世界:巫妖王之怒 经典版》的玩家都可以获得奖励。
更新日志
2024年10月27日
2024年10月27日
- 群星2013-青春缤纷辑压箱宝大公开3CD2[新加坡限量版][WAV整轨]
- 林育群.2013-BalladShow(日本版)【环球】【WAV+CUE】
- 陈加洛.1992-痛到感觉不到【宝丽金】【WAV+CUE】
- 群星.2023-宿命之敌电视剧原声带【韶愔音乐】【FLAC分轨】
- 東京事変-大発見[FLAC+CUE]
- 椎名林檎-三文ゴシップ[FLAC+CUE]
- 2024年08月04日
- 裘德《裘德「最后的水族馆」演唱会LIVE》[320K/MP3][228.89MB]
- 裘德《裘德「最后的水族馆」演唱会LIVE》[24bit 48kHz][FLAC/分轨][2.08G]
- 基因三重奏《如果你什么都不说 音乐会现场录音》[320K/MP3][145.37MB]
- 孟庭苇.1996-月亮说话(2020环球24KGOLD限量版)【上华】【WAV+CUE】
- 群星.1997-新艺宝优质音响系列·国语精选监听版【新艺宝】【WAV+CUE】
- 阿桑.2005-寂寞在唱歌(星外星引进版)【华研国际】【WAV+CUE】
- 基因三重奏《如果你什么都不说 音乐会现场录音》[FLAC/分轨][287.43MB]
- 蔡题谦《我爱你,却依然要看你走》[320K/MP3][88.65MB]