从所有人中删除各自的李 [英] Remove Respective Li from all

查看:113
本文介绍了从所有人中删除各自的李的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我的小提琴,当用户点击所有删除然后在foreach上为LI功能。我想在他们的输入字段中删除那些包含 abc,def,ghk 等名称的lis。我只想知道如何检查foreach循环上的活动li是否包含与其匹配的特定值输入字段是否值,所以我将停止删除它。 / p>

小提琴: http://jsfiddle.net/mT5vw/ 2 /

  $(document).ready(function(){
$(document)。 on('click','。liDelete',function(){
li = $(this).parent();
li.remove();
});
$(#butadd)。click(function(){
$(ul)。append(< li>文件夹名称:< input type ='text'class ='fname'value =''required ='required'/>< input type ='button'class ='liDelete'value =' - 删除'/>< / li>);
});
});

函数alldelete(){
$('#folder li')。each(function(e){});
}


解决方案

如果你想删除 li 输入包含类似 ABC的值尝试:

  $('#removeAll')。click(function(){
$('#folder li input [type =text]')。each(function(function) ){
if($(this).val()===abc){
$(this).parent()。remove();
}
});

这里 jsfiddle 只能在输入中写入 abc ,然后再按全部删除。


Following is my fiddle in which when user click on all delete then on foreach for LI function. I want to remove those lis which contains name like abc,def,ghk in their input field . I just want to know how to check that the active li on foreach loop contains the certain value that matches it input field value or not so i'll stop to remove it.

Fiddle: http://jsfiddle.net/mT5vw/2/

$(document).ready(function () {
    $(document).on('click', '.liDelete', function () {
        li = $(this).parent();
        li.remove();
    });
    $("#butadd").click(function () {
        $("ul").append("<li>Folder Name : <input type='text' class='fname' value='' required='required' /> <input type='button' class='liDelete'  value='- Remove' /></li>");
    });
});

function alldelete() {
    $('#folder li').each(function (e) {});
}

解决方案

If you want to remove the li that the input contains a value like ABC try:

$('#removeAll').click(function(){
    $('#folder li input[type="text"]').each(function () {   
       if ($(this).val() === "abc") {
           $(this).parent().remove();
        }
    });

here the jsfiddle only write abc in the input and before press remove all.

这篇关于从所有人中删除各自的李的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆