可能重复:
Finding whether the element exists in whole html page
我想做点什么:
<span id="one">one</span>
<span id="two">two</span>
<span id="three">three</span>JavaScript
if (isset($("#one"))){
alert('yes');
}
if (isset($("#two"))){
alert('yes');
}
if (isset($("#three"))){
alert('yes');
}
if (!isset($("#four"))){
alert('no');
}现场直播:
http://jsfiddle.net/8KYxe/
我怎么能做到呢?
发布于 2011-09-23 09:02:35
if (($("#one").length > 0)){
alert('yes');
}
if (($("#two").length > 0)){
alert('yes');
}
if (($("#three").length > 0)){
alert('yes');
}
if (($("#four")).length == 0){
alert('no');
}这就是你所需要的:)
https://stackoverflow.com/questions/7526554
复制相似问题