[英]get all html from span with jquery
<span class="get" attr-one="1" attr-two="2">text1</span>
<span class="get" attr-one="21" attr-two="2">text2</span>
<span class="get" attr-one="31" attr-four="2">text3</span>
<span class="get" attr-one="4" attr-three="2">tex4t</span>
<span class="get" attr-one="15" attr-five="2">text5</span>
<div id="container" style="width: 200px; height: 200px; background-color: red"></div>
$('.get').click(function(){
$('#container').append($(this).html());
})
如何使用HTML获取当前对象,并将其添加到其他容器? 在我的示例中,这仅获得我范围内的内容。 我想得到所有与abrributes等跨度
$('.get').click(function(){
$('#container').append($(this).clone());// to append html like with span now it will copy
})
要么
$('.get').click(function(){
$('#container').append($(this));// to append span now it will move
})
观看演示
$('.get').click(function(){
$('#container').append($(this));
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.