JQ知识点(20181203)

1、JQ函数直接加载

$(ducument).ready(function(){

})


2、JQ获取元素包含内容但是不获取其子元素内容

<div id='nav-btn'>
文本一
<span>文本二</span>
<span>文本三</span>
</div>

$("#nav-btn").contents().filter(function(){ 
    return this.nodeType == 3; 
})[0].nodeValue = "" ;


3、JQ获取元素内容并替换

<div class="box">我是box中的文本</div>
$('.box').text('替换成这个文本')


4、JQ获取属性并修改

<a class="box2" href=""></a>

<script type="text/javascript">
$(document).ready(function(){
	$('a.box2').attr('href','www.pinkpink.top')
})
</script>

猜你喜欢

转载自blog.csdn.net/PINK789/article/details/84776956