You can use $("#content").empty(); // empty the element with an id of 'content'
or $("#content div").remove() // find all divs within the element with an id of 'content' and remove them - Richard Richard D. Worth http://rdworth.org/ On Tue, Sep 16, 2008 at 4:50 PM, zephyr <[EMAIL PROTECTED]> wrote: > > Hi, > I have a <div id="content"> that serves as a placeholder for text. The > text are all like > > <div id="about"> > test test test > </div> > > <div id="links"> > link link link > </div> > > <div id="contact"> > [EMAIL PROTECTED] > </div> > > When the user clicks a link, I use it's id attribute value > ("about",contact" or "links"). I use that value to show the content of > the corresponding div in div "content". Div "content" is visible, the > others are invisible > I succeed in prepending() the div to div "content": > > activeElementId = $(this).attr('id') > $("div#content").prepend($("[EMAIL PROTECTED]"+activeElementId+"]").html()) > > > but if I do this in succession, new texts get appended to exisiting. > Of course I do not want this- I want the text "about" to be shown in > "content" or "links". Not both because append() appends! How can I > remove a div before showing another one? > > if(typeof(activeElementId) != "undefined"){ > $("div#content").remove($("div")) > } > > gives me an error "t.substring is not a function" when I click a > second link and only the first text is shown > > Thanks >