jquery dynamic id selector, remove then add class -


I have a line in which the div has a cell with all the rows in which div contains BTN- Insertidhere.

When the table row is selected, then I want to select this div id, then remove a class and change it to another. It wants to change a button image from an add symbol for a down signal which is for the clicked symbol.

Javascript code:

  $ ('* [class ^ = day] TD [id ^ = band]'). Live ('click', function) (var divId = $ (this) .find ('div.add'). Attr ('id'); alert adaxus ('del'); $ ('table # free_time tubs') Anden ($ (this)). Faidine (1000); Returned liars;});  

This is an html snippet of dynamically generated code:

  & lt; Tr id = "band-modest-mouse" & gt; & Lt; Td> Minor Mouse & lt; / Td> & Lt; TD & gt; 15: 25: 00 & lt; / TD & gt; & Lt; TD & gt; 16: 10: 00 & lt; / TD & gt; & Lt; TD & gt; 45 & lt; / TD & gt; & Lt; Td> Div id = "btn-mild-mouse" square = "add" & gt; & Amp; Nbsp; & Lt; / Div & gt; & Lt; / Td> & Lt; / TR & gt;  

As you can see, I want to change the 'add' class to 'del' class. All table rows are generated on the table in such a way that you can see that I have gone to the wildcard approach, which seems to be working because the warning is shown, the correct Divi ID shows. I just need to change the class!

Thank you!

You can either type '.attr (id)' part

  Var divId = $ (this) .find ('div.add') and get the jq object for div; ... $ (DivId) .removeClass ('Add'). AddClass ('del'); Add  

or divId selector <# p>

  $ ("#" + divId) .removeClass ('Add'). AddClass ('del');  

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -