Asp,Php,Jssdk,mysql,mssql,微信公众号开发,小程序开发-学习笔记 收集日常学习笔记和重点,交流QQ:79657181,手机/微信:18611436777

jquery元素内和元素前后添加文字

<button id="hxjxjs" type="button">元素内文字后加内容</button>

<button id="hxjn" type="button">元素内文字前加内容</button>

<button id="xjswzr" type="button">元素外元素后面加内容</button>

<button id="xjgnxg" type="button">元素外元素前面加内容</button>

<div class="anco">

中国电信:

</div>


<script type="text/javascript">

$(document).ready(function(){//页面加载完在执行jq

$('#hxjxjs').click(function(){

$('.anco').append('号段是133,189')//支持加入div或是html代码

});

$('#hxjn').click(function(){

$('.anco').prepend('中国联通比电信好')

});

$('#xjswzr').click(function(){

$('.anco').after('你看看是不是在div外面加的,外面的后面')

})

$('#xjgnxg').click(function(){

$('.anco').before('这是在div前面加了字')

})


});

</script>


2018年8月3日 | 发布:anco | 分类:jquery | 评论:0