我想通过JavaScript或jquery接受in.find并在span.label元素下替换它 是否有任何功能
<span id="flat_title" class="ddTitleText ">
<img class="fnone" src="images/pinc.png">
<span class="ddlabel">A</span>
<span class="description" style="display: none;"></span>
</span>
答案 0 :(得分:2)
使用append()
var targetSPAN=$('#flat_title');
var image=$('img.fnone', targetSPAN);
$('span.ddlabel', targetSPAN).append(image);
答案 1 :(得分:0)
<script type="text/javascript">
$(document).ready(function () {
$('span .ddlabel').append('<img class="fnone" src="images/pinc.png">');
$('#flat_title img:first').remove()
});
</script>
答案 2 :(得分:0)
使用element.appendChild方法。
<span id="flat_title" class="ddTitleText ">
<img class="fnone" src="images/pinc.png" />
<span class="ddlabel">A</span>
<span class="description" style="display: none;"></span>
</span>
<div>
<button id="abc">Click to replace</button>
</div>
<script>
document.getElementById('abc').addEventListener('click',function(){
var parent = document.getElementById('flat_title'),
img = document.getElementsByClassName('fnone')[0],
description = document.getElementsByClassName('description')[0];
parent.appendChild(img);
parent.appendChild(description);
})
</script>
上查看
答案 3 :(得分:0)
使用html()
var html=$("img.fnone").html();
$("span.ddlabel").html(html);
$("img.fnone").remove();