I have a button in my table, I want to remove a complete row on button click.?
please dont try to modify the logic i used.
Currently when the button is clicked I get its id and based on that id i need to delete an element(complete row) from the DOM having same class name.
JavaScript
$(".removeAKA").click(function () {
// alert($(this).val());
var id = this.id;
alert(id);
$("." + id).remove();
});
HTML
<tr class="aka 1" id="sdf">
<td>AKA 1</td>
<td><input class="text-box single-line" id="aka_1_" name="aka[1]" type="text" value="2" /></td>
<td><input type="button" class="removeAKA" id="aka 1" value="Delete" /></td>
</tr>
Hiya demo if you want to keep the spaces: http://jsfiddle.net/59RA2/9/ OR http://jsfiddle.net/59RA2/31/ OR http://jsfiddle.net/59RA2/32/
Hope this helps.
I have replaced spaces to
.because spaces is not recognized when Jquery tries interpreting your code.or
You can also use
$(this).closest('tr').remove();to remove the row.or
You can use
$("table ."+id).remove();Further:
jQuery: selector (classname with space)
jQuery remove table row with non-standard id characters
Quote
Code
just replace spaces with . and it will work if you want to else you can have no spaces in-between.
Have a good one, cheers!