jquery - Looking to simplify adding an attribute based on sibling's text -


I would like to add a title attribute to a line and the price is taken from the brother of that line which is hidden, as long as Not clicked I wanted to handle it normally when some screen does not have a hidden row with text.

This is the first pass that works:

  $ (function () ($ ("td.commandText pre"). Each (function (index) {$ (This) .Parent () .Parent (). Attr ('title', $ (this) .text ());});});  

To make the idea even more elegant?

Here's an example of the HTML table I'm working on:

   class = "merridrid "& Gt; & lt; thead & gt; & lt; TR & gt; & lt; th & gt; session id & lt; / th & gt; & lt; th & gt; Username & lt; / th & Gt; & lt; th & gt; Start time & lt; / th> & lt; th & gt; Termination Y  & lt; / tr & gt; & lt; / thead & gt; & lt; tbody & gt; & lt; tr square = "record" & gt; & lt; td id = "174" & gt; 174 & lt; / td> & lt; TD & gt; user1 & lt; / td & gt; & lt; td & gt; 8/2/2010 4:00:09 PM Lt; / td> & lt; TD & gt; & lt; / TD & gt; & lt; / tr & gt; & lt; tr & gt; & lt; td class = "Hide description command text" Colspan = "4" & gt; & lt; Pre & gt; Sample text to show as tooltip & lt; / Pre & gt; & Lt; / Td> & Lt; / TR & gt; & Lt; TR & gt; & Lt; Td square = "hide description" colspan = "4" style = "color: red" & gt; & Lt; Pre & gt; Any errors & lt; / Pre & gt; & Lt; / Td> & Lt; / TR & gt; & Lt; Tr square = "record" & gt; & Lt; Td id = "175" & gt; 175 & lt; / A & gt; & Lt; / Td> & Lt; TD & gt; User1 & lt; / TD & gt; & Lt; Td> 8/2/2010 4:00:09 PM & lt; / Td> & Lt; TD & gt; & Lt; / TD & gt; & Lt; / TR & gt; & Lt; TR & gt; & Lt; Td square = "hide description command text" colspan = "4" & gt; & Lt; Pre & gt; Sample text to show as tooltip & lt; / Pre & gt; & Lt; / Td> & Lt; / TR & gt; & Lt; TR & gt; & Lt; Td square = "hide description" colspan = "4" style = "color: red" & gt; & Lt; Pre & gt; Any errors & lt; / Pre & gt; & Lt; / Td> & Lt; / TR & gt; & Lt; / Tbody & gt; & Lt; / Table & gt;  

You can use it to minimize, like:

Every (task) {$ (this) .clostest ('tr'). Prev (). Attr ('title') ('title' ('td.commandtext pre), $ (this) .text () );});});

Besides, there is not much beauty to achieve here.


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -