当前第2页 返回上一页
放到代码里
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | <script type= "text/javascript" >
var number = (1+Math.random()*(8-1)).toFixed(0);
var oBox2=document.getElementsByTagName( 'div' )[0];
var oBox1=document.getElementById( 'box1' );
if (number<3){
document.body.removeChild(oBox1);
}
if (document.getElementById( 'box1' )){
oBox2.className=oBox2.className+ ' box22' ;
console.log(111);
}
else {
oBox2.className= 'box2' ;
}
</script>
|
jquery方法
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | <script src= "jquery-1.8.3.min.js" ></script>
<script type= "text/javascript" >
var number = (1+Math.random()*(8-1)).toFixed(0);
if (number>3){
}
else {
$( '#box1' ).remove();
}
if ($( '#box1' ).length>0){
$( '.box2' ).addClass( 'box22' );
}
else {
$( '.box2' ).removeClass( 'box22' );
}
</script>
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | <script src= "jquery-1.8.3.min.js" ></script>
<script type= "text/javascript" >
var number = (1+Math.random()*(8-1)).toFixed(0);
if (number>3){
}
else {
$( '#box1' ).remove();
}
if ($( '#box1' )[0]){
$( '.box2' ).addClass( 'box22' );
}
else {
$( '.box2' ).removeClass( 'box22' );
}
</script>
|
每天进步一点点,努力超越昨天的自己。
【推荐学习:javascript高级教程】
以上就是JavaScript如何判断节点是否存在的详细内容,更多文章请关注木庄网络博客!
返回前面的内容
相关阅读 >>
如何使用javascript消除readonly
javascript中localstorage的用法注意点介绍
检测javascript里最有效率的功能特征的方法解析
javascript中定义方法的关键字是什么
javascript中的运算符有哪些
javascript的fcous什么意思
javascript如何改变原数组
移动端h5中百度地图的click事件的介绍(代码示例)
js如何使用索引访问数组对象中的元素
js中什么是原型链
更多相关阅读请进入《javascript》频道 >>
人民邮电出版社
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者
转载请注明出处:木庄网络博客 » JavaScript如何判断节点是否存在