How To Remove The Content In The Td Tag Using Jquery May 30, 2024 Post a Comment I have a table defined like ButtonSolution 1: If you want to remove the complete contents of that previous TD (rather than a specific INPUT element), this will work:$(document).on("click", "#first", function() { $(this).closest("td").prev().empty(); }); CopySolution 2: http://jsfiddle.net/sfHBn/1/$(document).on("click", "#first", function() { $(this).closest("td").prev().html(""); }); CopyThis will remove all content in previous td tag.Solution 3: You should go up the DOM tree until parent <td>, then get previous <td>, find <input> inside and remove it. You should use on() with event delegation instead of deprecated live():$(document).on("click", "#first", function() { $(this).closest("td").prev().find("input").remove(); }); CopyNote, that instead of document you may use any other static parent element of #first.Solution 4: I suggest you to use .on() instead because .live() is been now removed from the jQuery version 1.9+:$(document).on('click', "#first", function(){ $(this).closest('td').prev().children().remove(); }); CopyClick the #first button and get to the .closest()<td> and get the .prev() element which is a <td> as well then .remove() its .children().Solution 5: Here is the one liner to achieve. $(this).closest("td").prev().remove(); Copy Share Post a Comment for "How To Remove The Content In The Td Tag Using Jquery"