Use jQuery to delete HTML table rows by clicking it-Ultra simple, jquery table

Source: Internet
Author: User

Use jQuery to delete HTML table rows by clicking it-Ultra simple, jquery table

JQuery has become one of the most common and favorite JavaScript frameworks at all times. It not only reduces the technical overhead of simple JavaScript encoding, but also makes your code cross-browser compatible. I have already written many jQuery tutorials. At this time, I also use this simple pure implementation. The task is to use some trendy effects from an HTML table, as long as you click the row of the row. The following is the jQuery code to achieve this goal.

$(document).ready(function() {     $("#sample tr").click(function() {         //change the background color to red before removing         $(this).css("background-color","#FF3700");                  $(this).fadeOut(400, function(){             $(this).remove();         });     }); });

 

In the above Code, we have attached all the "TR" handlers in the "# example" table. Next, we first change the background of the row, then fade out and delete it. This is a simple task.


How can I create a table when I click the html button?

With jquery, this is simple. You can try Baidu again. The following is a reference:
$ ("# Button"). click (function (){

$ ("Table"). append ("<tr> <td> </tr> ");
}

Daxia helps write a Jquery code to delete table rows.

<Html xmlns = "www.w3.org/5o/xhtml">
<Head>
<Title> </title>
<Script type = "text/javascript" src = "js/jquery-1.2.3-intellisense.js"> </script>
<Script type = "text/javascript">
Function shanchu (){
$ (This). parent (). parent (). remove ();
}

$ (Function (){
$ ("A"). click (shanchu );
})
</Script>
</Head>
<Body>
<Table>
<Tr>
<Td> xxxx </td> <a href = "#"> Delete </a> </td>
</Tr>
</Table>
</Body>
</Html>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.