Can I manipulate a <div> with jQuery?
So if I have:
Can I change class names, and add further HTML, e.g. to create this:
<div id="the-div" class="new-class">
Can someone point me in the right direction?
This is absolutely 100% possible with jQuery and because all the cross browser issues are solved in the library itself we don't need to worry about IE causing us headaces, see the folllowing jsFiddle link as i put together a very simple demo to do the above.
Also if you ever get stuck simply visit the jQuery docs page http://docs.jquery.com/Main_Page as it always has the information you need when you get stuck.
Thanks. I can see how to get an element and add and change things. I also notice the 'after' command which could be useful.
But, what about getting all id names inside another div:
Above returns 'id-name-1' and 'id-name-2' when looking inside a div with the class name 'class-name'.
That sounds like a completely different story. I'm guessing it's possible with jQuery though??
Thanks again for taking the time to write a demo.
This is another simple concept to create in practice but I do understand if you are new to jQuery in general so forgive me if I begin to sound like a know it all :), see the following jsFiddle which again shows you how to achieve the above.
This topic is now closed. New replies are no longer allowed.