PDA

View Full Version : Updating HTML Div Class or Content



ssdesign
27 Jul 2010, 1:05 AM
If I have a html defined in one of my items as this:


html: '<div class="something">Sometext</div>'

and then during the course of using this app, if I want to update it to something else, like:


html: '<div class="anotherthing">Sometext</div>'

what would be the best way to do that?

Regards

evant
27 Jul 2010, 1:10 AM
Untested:



var el = body.child('.something');
el.removeClass('something').addClass('anotherthing');

ssdesign
27 Jul 2010, 5:21 PM
Hi,
Thanks for your reply.

Will this replace all the '.something' classes in the document of just a specific one from a specific [item]?

evant
28 Jul 2010, 12:09 AM
From the docs for child:



Selects a single *direct* child based on the passed CSS selector (the selector should not contain an id).

ssdesign
17 Aug 2010, 10:19 AM
oops sorry wrong thread