大佬教程收集整理的这篇文章主要介绍了使用jQuery从字符串中删除HTML标记,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
<input type="checkBox" id="list-item-x" /> <label for="list-item-x"><span class="date">Oct 1</span> The checkBox label</label>
我想要label元素,但没有span.date.我该如何删除?我尝试过以下方法:
$('label').remove('span.date').text();
这不起作用,以下情况也没有:
$('label').find('span.date').text();
编辑:这是整个(凌乱)代码:
$('input.list-item-checkBox').live('click',function(){ var myself = $(this); var my_id = $(myself).attr('id').split('-',3); my_id = parseInt(my_id[2]); var my_label = $(myself).parent().children('label').html(); var parent = $(myself).parents('.list-item'); if ($(this).is(':checked')) { $.ajax({ type: 'POST',url: CI.base_url + 'ajax/unfinished_item/',data: 'list-item=' + my_id,dataType: 'json',success: function(result){ if (result.status == 'ERROR') { alert('Could not edit item'); } else { var html_@R_673_10495@ng = '<div class="list-item">' + ' <input type="checkBox" class="list-item-checkBox" id="list-item-' + my_id + '" /> ' + ' <label for="list-item-' + my_id + '">' + my_label + '</label>' + '</div>'; $(myself).parents('.list-finished').siblings('.list-items').append(html_@R_673_10495@ng); $(myself).parents('.list-item-finished').remove(); // This is where I need to get the span element removed from the label } },error: function(){ alert('No contact with server'); } }); } });
以上是大佬教程为你收集整理的使用jQuery从字符串中删除HTML标记全部内容,希望文章能够帮你解决使用jQuery从字符串中删除HTML标记所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。