Example of how JQuery operates tr and td content

Source: Internet
Author: User

Copy codeThe Code is as follows:
<PRE class = html name = "code"> <Head id = "Head1" runat = "server">
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
<Link href = "../esstec_css/style.css" type = "text/css" rel = "stylesheet" media = "all"/>
<Link href = "../esstec_css/style.nk.css" rel = "stylesheet" type = "text/css"/>
<Script src = "./js/jquery-1.7.2.min.js" type = "text/javascript"> </script>
<Link href = "../esstec_css/Default.css" rel = "stylesheet" type = "text/css"/>
<Link href = "../esstec_css/BMS-Form.css" rel = "stylesheet" type = "text/css"/>
<Script type = "text/javascript">
$ (Document). ready (function (){
$ ("# SelEmployee"). click (function (){
Var $ table = $ ("# tbProEmployee tr ");
Var len = $ table. length;
Var trid = "tbProEmployee" + len;
Var strDeviceTr = "<tr id =" + trid + "> ";
StrDeviceTr + = "<td> <input id = \" txtEmployeeInnerID \ "type = \" hidden \ "name = \" ProjectEmployee \ "value = \" "+" 123 "+ "\"/> <input id = \ "txtInnerID \" type = \ "hidden \" name = \ "ProjectEmployee \" value = \ "\"/> ";
StrDeviceTr + = "<label id = \" txtEmployeeName \ ">" + "name" + "</label> </td> ";
StrDeviceTr + = "<td> <input id = \" txtRemark \ "type = \" text \ "name = \" ProjectEmployee \ "/> </td> ";
StrDeviceTr + = "<td> <a href = \" javascript:; SaveProEmployee ('"+ trid + "') \ "> Save </a> | <a href = \" javascript:; DelProEmployee ('"+ trid + "') \ "> Delete </a> </td> ";
StrDeviceTr + = "</tr> ";
$ ("# TbProEmployee"). append (strDeviceTr );
});
});
Function SaveProEmployee (index ){
// Save with ajax
Var tr = $ ("tr [id =" + index + "]");
Var employee = tr. find ("# txtEmployeeName"). text ();
Var remark = tr. find ("# txtRemark"). val ();
Var strtd = "<td> <input id = \" txtEmployeeInnerID \ "type = \" hidden \ "name = \" ProjectEmployee \ "value = \" "+" 123 "+ "\"/> <input id = \ "txtInnerID \" type = \ "hidden \" name = \ "ProjectEmployee \" value = \ "\"/> ";
Strtd + = "<label id = \" txtEmployeeName \ ">" + employee + "</label> </td> ";
Strtd + = "<td> <label id = \" txtRemark \ ">" + remark + "</label> </td> ";
Strtd + = "<td> <a href = \" javascript:; UpdateProEmployee ('"+ index + "') \ "> modify </a> | <a href = \" javascript:; DelProEmployee ('"+ index + "') \ "> Delete </a> </td> ";
Tr.html (strtd );
}
Function UpdateProEmployee (index ){
// Save with ajax
Var tr = $ ("tr [id =" + index + "]");
Var employee = tr. find ("# txtEmployeeName"). text ();
Var remark = tr. find ("# txtRemark"). text ();
Var strtd = "<td> <input id = \" txtEmployeeInnerID \ "type = \" hidden \ "name = \" ProjectEmployee \ "value = \" "+" 123 "+ "\"/> <input id = \ "txtInnerID \" type = \ "hidden \" name = \ "ProjectEmployee \" value = \ "\"/> ";
Strtd + = "<label id = \" txtEmployeeName \ ">" + employee + "</label> </td> ";
Strtd + = "<td> <input id = \" txtRemark \ "type = \" text \ "name = \" ProjectEmployee \ "value = \" "+ remark + "\ "/> </td> ";
Strtd + = "<td> <a href = \" javascript:; SaveProEmployee ('"+ index + "') \ "> Save </a> | <a href = \" javascript:; DelProEmployee ('"+ index + "') \ "> Delete </a> </td> ";
Tr.html (strtd );
}
Function DelProEmployee (index ){
If (confirm ("Are you sure? ")){
$ ("Tr [id =" + index + "]"). remove ();
}
}
</Script>
</Head>
<Body>
<Form id = "form1" runat = "server">
<Div class = "snippet download-list">
<Table class = "telerik-reTable-2" id = "tbProEmployee">
<Tbody>
<Tr>
<Th colspan = "3">
[<A id = "selEmployee" href = "javascript: void (0)"> operator </a>]
</Th>
</Tr>
<Tr>
<Th>
Name
</Th>
<Th>
Remarks
</Th>
<Th>
Operation
</Th>
</Tr>
</Tbody>
</Table>
</Div>
</Form>
</Body>
</Html> </PRE> <BR>
<BR>
<PRE> </PRE>
<PRE> </PRE>

Related Article

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.