Help me please on this jquery: I want remove row if value is '0' but until now on this code, I Just can remove all
$('#refresh').click(function(){
var tableDestination = $('#example');
var countTable = tableDestination.length;
for(var i = 1; i <= countTable; ++i) {
$('.checklist').each(function(i) {
var value = $('.checklist').eq(i).val();
if (value != 1) {
//Test Run PerRow
alert('DeleteValue=' + value + ' ' + 'RowValue=' + i);
$('tr#DelRow').remove(i);
}
else{
alert('HoldValue=' + value + ' ' + 'RowValue=' + i);
}
});
$('tr#DelRow').remove(i);
}
});
I'm using switch case LIKE
switch(value){
case '0':
//Test Run PerRow
alert('DeleteValue=' + value + ' ' + 'RowValue=' + i);
break;
case '1':
//Test Run PerRow
alert('HoldValue=' + value + ' ' + 'RowValue=' + i);
break;
}
I want keep the green checklist and red cross to remove
this is Result : http://i.stack.imgur.com/jMocu.png
The following will remove all rows from a table which have a column that contains an <input>
element that has a value
of 0
. It is executed when a button on the page is clicked. A jsFiddle is provided to illustrate.
$(function () {
$('#refresh').click(function () {
$("#example tr:has(input[value='0'])").remove();
});
});
The core of the work is in the jQuery selector which is #example tr:has(input[value='0'])
. The way to read this is:
id
of example
. This will be the table.tr
(table row) children of the table which contain an input
element that has a property value
of 0
.When we have the list, we execute the jQuery .remove() to remove them from the DOM.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다