$("body").on("click", ".search-results li", function(){
$(this).appendTo(".creating-wrapper .recipients");
});
我想删除用户执行搜索时应用于文本的<strong></strong>
标记。
附加的html如下所示:
<li class="highlight-off" rel="<?php echo $userID?>">
<div class="left"><img class="photo" src="<?php echo photo($userID, 35)?>"/></div>
<div class="right">
<div class="name"><?php echo highlight($term, str_replace(" "," ", name($userID)))?></div>
</div>
</li>
另外,我还想做的另一件事就是删除整个<div class='left'></div>
及其元素
谢谢!
答案 0 :(得分:1)
应该只是jQuery魔术。
var $append = $( this );
$append.find( 'div.left' ).remove();
$append.find( 'strong' ).contents().unwrap();
$append.appendTo(".creating-wrapper .recipients");
答案 1 :(得分:1)
这个怎么样?
$("body").on("click", ".search-results li", function(){
$(this).find('div.left').remove();
$(this).find('strong').each(function() {
$(this).after($(this).text()).remove();
});
$(this).appendTo(".creating-wrapper .recipients");
});