Forums

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

Home Forums CSS Replace Entire divs with Jvascript

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #43026
    Anonymous
    Inactive

    I want to replace an entire div with another using this type of javascript code

    function myFunction()
    {
    x=document.getElementById(‘demo’);
    x.innerHTML=”div replaced”;
    }

    Although im not sure how to do it. Ive done it with text but never with styled divs. It’s to replace the iframe on this website [WEBSITE](http://reallycoolstuff.net/PROJECTS/JV/ “”)

    If there’s an easier, more effective way of doing this im open to suggestions.

    #126384
    Paulie_D
    Member

    When you say replace…how will this happen?

    On a click or something else?

    Are you replacing one iframe with another?

    If JS were turned off…would you want the new content to show anyway?

    #126386
    Anonymous
    Inactive

    @Paulie_D I’m simply replacing a div depending on the navigation bar that is clicked. I’m not replacing iframes. You can see the text inside the ribbon change when a navigation tab is clicked. Thats basically what i want to do but with divs instead. And it will happen on onclick=”myFunction()”

    #126398
    Anonymous
    Inactive

    @srig Thanks. i Knew there was an easier way but i’m still learning Javascript. Are there any other problems you see with my code?

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