国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

jQuery 屬性選擇器element[herf*='value']使用示例

2024-05-06 15:53:16
字體:
來源:轉載
供稿:網友
一個針對jQuery屬性選擇器的小例子,增加對jQUery屬性選擇器的理解,感興趣的朋友可以參考下

一個針對jQuery屬性選擇器的小例子,增加對jQUery屬性選擇器的理解:

復制代碼 代碼如下:


<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<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></div>
<ol>
<dt>
<input type="button" 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" value="name*='man'"/><br><br>
<input>
<input><br>
<input>
<input>
</dt>
<dt>
<input type="button" value="input[name~='man']"/><br><br>
<input>
<input><br>
<input>
<input>
</dt>

<dt>
<input type="button" value="input[name$='letter']"/><br><br>
<input>
<input><br>
<input>
</dt>

<dt>
<input type="button" value="input[value='Hot Fuzz']"/><br><br>
<div>
<label>
<input type="radio" value="Hot Fuzz">
<span>name?</span>
</label>
</div>
<div>
<label>
<input type="radio" value="Cold Fusion">
<span>value?</span>
</label>
</div>
<div>
<label>
<input type="radio" value="Evil Plans">
<span>value?</span>
</label>
</div>
</dt>

<dt>
<input type="button" value="input[name!='newsletter']"/><br><br>
<div>
<input type="radio" 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" value="Evil Plans">
<span>name is accept</span>
</div>
</dt>

<dt>
<input type="button" value="input[name^='news']"/><br><br>
<input>
<input><br>
<input>
</dt>

<dt>
<input type="button" value="div[id]"/><br>
<div>no id</div>
<div>with id</div>
<div>has an id</div>
<div>nope</div>
</dt>

<dt>
<input type="button" value="input[id][name$='man']"/><br><br>
<input>
<input><br>
<input>
<input>
</dt>

<dt>
<input type="button" value="clearEffects"/>
</dt>
</ol>
</body>
</html>

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 丹巴县| 莎车县| 祁东县| 桐柏县| 湘乡市| 望奎县| 土默特右旗| 神木县| 景德镇市| 商水县| 阿瓦提县| 汤阴县| 萨迦县| 邓州市| 广丰县| 泽普县| 雅江县| 喜德县| 南城县| 萝北县| 乐亭县| 中牟县| 长沙市| 鞍山市| 新乡县| 平陆县| 内黄县| 南丹县| 霍山县| 揭阳市| 兴山县| 通山县| 汽车| 阿城市| 新津县| 丹寨县| 广安市| 普兰县| 梁平县| 广宗县| 鄱阳县|