The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript change html contents via javascript

  • This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
  • #35561

    How can I change the contents of my paragraph as well as the contents of my list once the link was clicked. reference:

    once i click woven badges on the navigation carousel i want to change the contents of the p as well as the imaged displayed. Is that possible via javascript? Is it a great alternative rather than creating a bunch of html pages for every page which has the same layout but different contents.

    I’m looking forward to detailed solutions.Thanks


    easiest way out for todays browsers is to label the element of the section that is supposed to change. Here’s an example of what I mean…

    <div ID=”ABC”>change me</div>

    So above, we want to change the text “change me”.

    then in javascript, use commands like this:

    var mystuff=getElementById(“ABC”);

    The first command (I may have missed an S or messed up on capitalization) will create a variable to hold an internal value which is the same as the DIV above.
    The second command modifies the html data between “<div ID=”ABC”>” and “</div>”.


    damn…. the code didnt work… ill try again…
    just type all this in.

    Text to change

    Once this is run, you should see “Changed!”


    well that’s good. but how bout this? it aint simpy tags and text.

  • #92449

    Hi saberExcalibur7!

    You’ll need to share a bit more information before we can help you. How are you planning on getting the new information? I’m guessing that when an item is clicked inside of the “.overview” window that you want the information inside of “#content” to update with the new item. And this new information is obtained via ajax?

    Basically, once you get the new information, you can just target the “#content” div, as mik3ca shared, and replace everything inside of it. But you’ll also need to re-initialize the jqzoom plugin for the new image.


    Why not just use Ajax then you can just store all new content in a separate text file. Seems like the easiest way to me. Just use the XMLHttpRequest object.


    Actually just check out the jQuery .load method, that seems to be the best way, cheers:)

Viewing 7 posts - 1 through 7 (of 7 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.