javascript - jquery .find/.closest/.next -


I have a row that is below 4 cells

   & Lt; / TD & gt; & Lt; Td style = "width: 116px" & gt; & Lt; Asp: checkbox runat = "server" id = "rcp" type = "checkbox" enabled = "wrong" /> & Lt; / TD & gt; & Lt; Td id = "RC2" class = "contLabel" & gt; Related companies are used to improve the results? & Lt; / Td> & Lt; / TR & gt;   

And under the table, I have a text box inside the box, the code is below:

  & lt; Div id = "rcn" class = "panel2" style = "width: 100%;" & gt; & Lt; div class = "contentTB" & gt; & Lt; ASP: Text Box ID = "RCnt" Runat = "Server" Textual = "Multiline" width = "99.5%" enabled = "wrong" & gt; & Lt; / Asp: text box & gt; & Lt; / Div & gt; & Lt; / Div & gt;   

What I want to achieve is the moment, I click on the first cell (# RC) or the fourth cell (# RC2), the text box toggle under the table , Currently my jquery code is

  $ (function () {$ ('# rc, # rc2).) (Function (e) {$ (' # rcn '). Toggle ('sharp');});})   

And it works fine.

The problem now is that I have 20 tables and 20 text boxes, and I do not want to write jquery lines 20 lines. I am trying to do things

  $ ('.contlabel'). Click (function (e) {$ (this) .next ('. Panel 2') Toggle ('sharp');});   

But that does not work. I wonder what is the correct code?

The reason for this is that I do not keep them all in a table that this toggle animation does not look good.

Thanks for any advice!

You can use table by closest () then the next () to get the div from Texter in it.

  $ ('.contlabel'). 'Click', function (e) {var $ td = $ (this); $ Td.closest ('table'). Next ('.panel 2') Toggle ('sharp');});    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -