简体   繁体   中英

remove element li depending on value of input element inside li JQuery

I have a list with li 's

<li><label><input type='checkbox' class='className'  value='" + someID + "' /> Some Name </label></li>

The way I create li 's

var container= "#checkbox-menu"
var tempElement ="<li><label><input type='checkbox' class='className'  value='" + someID + "' /> Some Name </label></li>";
$(container).append(tempElement);

I need to delete li element where value in input is equal to someID .

I came up with something like this

$("#checkbox-menu li:has('label'):has(input[value='"+ someID +"'])").remove()

But it didnt work.

Thank You for help in advance.

我不确定我到底找错了什么,但似乎您只想使用此行删除函数中的li:

$('input[value="' + someID + '"]').parents('li').remove();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM