Turn: jquery traverses the content of TD in TR in table

Source: Internet
Author: User

1. $ ("# trid TD"). Text () returns a string for the value of TD in the trid.

2. $ ("# trid "). children obtains all TD information under a trid and then traverses $ ("# trid "). children use. eq (index ). text () to get the value in TD;

  1. <! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <HtmlXmlns=Http://www.w3.org/1999/xhtml">
  3. <Head>
  4. <MetaHTTP-equiv="Content-Type"Content="Text/html; charset = gb2312"/>
  5. <Title>Untitled document</Title>
  6. <ScriptLanguage="JavaScript"SRC=Jquery-1.6.2.min.js"Type="Text/JavaScript"></Script>
  7. <ScriptLanguage="JavaScript">
  8. $ (Document). Ready (function (){
  9. $ ("# Table A"). Each (function (){
  10. This. onclick=Function(){
  11. VaRThisobj=This. Parentnode. parentnode;
  12. VaRA= $ (Thisobj). Children ();
  13. VaRArr=NewArray ();
  14. VaRLaber= $ ("# Xiugai label ");
  15. For (VARI=0; I<A. Length; I ++ ){
  16. Arr [arr. Length] = A. eq (I). Text ();
  17. }
  18. For (VARI=0; I<Laber. Length; I ++ ){
  19. Laber. eq (I). Text (ARR [I]);
  20. }
  21. $ ("# Table"). Hide ();
  22. $ ("# Xiugai"). Show (2000)
  23. }
  24. });
  25. });
  26. Function fanhui (){
  27. $ ("# Table"). Show (2000 );
  28. $ ("# Xiugai"). Hide (2000 );
  29. }
  30. </Script>
  31. </Head>
  32. <Body>
  33. <DivID="Table">
  34. <TableWidth="470"Border="0"Cellspacing="0"Cellpadding="0">
  35. <TrID="Tr1">
  36. <TD>ID</TD>
  37. <TD>Name</TD>
  38. <TD>Password</TD>
  39. <TD>Operation</TD>
  40. </Tr>
  41. <TrID="Tr2">
  42. <TD>1</TD>
  43. <TD>Zhang San</TD>
  44. <TD>12</TD>
  45. <TD><AHref="#">Delete</A></TD>
  46. </Tr>
  47. <TrID="TR3">
  48. <TD>2</TD>
  49. <TD>Li Si</TD>
  50. <TD>34</TD>
  51. <TD><AHref="#">Delete</A></TD>
  52. </Tr>
  53. <TrID="Tr4">
  54. <TD>3</TD>
  55. <TD>Wang Wu</TD>
  56. <TD>56</TD>
  57. <TD><AHref="#">Delete</A></TD>
  58. </Tr>
  59. <TrID="Tr5">
  60. <TD>4</TD>
  61. <TD>Cat6</TD>
  62. <TD>78</TD>
  63. <TD><AHref="#">Delete</A></TD>
  64. </Tr>
  65. </Table>
  66. </Div>
  67. <DivID="Xiugai"Style="Display: none; Background-color: # FFC; Height: 360px; width: 260px">
  68. ID:<Label></Label><BR/>
  69. Name:<Label></Label><BR/>
  70. Password:<Label></Label><BR/>
  71. <ButtonOnclick="Fanhui ()">Return</Button>
  72. </Div>
  73. </Body>
  74. </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.