I am creating an app where it is required to add or delete lines to a HTML
table.
I programmed the function to add a line to the table in jQuery
, like:
function othaddrAddLine(evt) {
var oarow = $("span#othaddrRowToAdd > table > tbody").html();
$("div#tabs-othaddrs > table#TableOthAddr > tbody").append(oarow);
}
$(document).ready(function () {
$("button#othaddr-add").click(othaddrAddLine);
$("button#othaddr-del").click(othaddrDelLine);
});
where that span
contains hidden text.
Now I want to program the othaddDelLine
function, where I want to delete the line of the table that was in focus.
How can I program this in jQuery
or JavaScript
? Is it possible to get the text input control where the caret was, in order to get the parent <tr>
element and then delete the row.
Thank you.