html - Get the value of children in jquery -


How to get the value of the cell in the table when the user clicks on the next cell?

  & lt; Table ID = "registrarable" & gt; & Lt; C: forEach item = "$ {requestScope.AllUsers}" var = "user" varStatus = "loop" & gt; & Lt; Tr class = "userRow" & gt; & Lt; Td class = "numberwidth" & gt; $ {Loop.index + 1} & lt; / Td> & Lt; Td class = "nameWidth user" id = "$ {user.userno}" & gt; $ {User.fullName} & lt; / Td> & Lt; TD & gt; & Lt; Button name = "disable BTN" id = "idle" class = "passive BTN" & gt; Deactivate & lt; / Button & gt; & Lt; / TD & gt; & Lt; / TR & gt; & Lt; / C: foreach & gt; In Jquery,   

I want to get the value of "edi" from the second td when users click on the inactive button.

I've made it like this

  var userNo = $ ('td.user', $ (this) .parents (". UserRow")) Attr ('id');   

and like it

  var userNo = $ ($ (this) .Parent (". UserRow") & gt; "td"). Attr ("id");   

No one else works!

  $ ('#deactivate'). Click (function () {var users not = $ (this) .Parent (). PrevAll ('td.user'). Attr ('id');});   

with the button (which is this ), parent ( td> with disabled buttons) . Then, the last brother & lt; Td> Get the class with user , and id attribute.

Alternatively, if you do not want to rely on the fact that the deactivation button will change the & lt; Td> After a & lt; Td> , you can do so: <('Td.user'). ('TD.') (". ID");});

Which is & lt; Tr & gt; with closest and then & lt; Td class = "user" & gt; Find with .

Li> -

  • -
  • find the code () -

  • Comments

    Popular posts from this blog

    mysql - BLOB/TEXT column 'value' used in key specification without a key length -

    c# - Using Vici cool Storage with monodroid -

    python - referencing a variable in another function? -