Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8308445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:49:06+00:00 2026-06-08T18:49:06+00:00

I have a span and 5 different html structures which basically involve lists and

  • 0

I have a span and 5 different html structures which basically involve lists and divs.

I have 5 buttons. Clicking on each button should change the content of the span to one of these structures.

I know that it can be done as easily as using

document.getElementById("a").innerHTML = "<div> A </div>";

But if I have an html structure of 20-30 lines, is this the best approach? Or is there any better way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T18:49:07+00:00Added an answer on June 8, 2026 at 6:49 pm

    If you are going to have a bunch of such buttons, you should utilize a function that you can call with passed data in order to not have to rewrite thing voer and over again something like

    function insertHTML(id, content) {
        document.getElementById(id).innerHTML = content;
    }
    

    Then you can just put an onclick function on you button item like this:

    <div class="button" onclick="insertHTML('idoftarget', '<div>html</div>')"></div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have different spans in my HTML with each decimal ID's: <span id=1>Lorem Ipsum</span>
I have the following list in HTML: <ul> <li><span class=button>A</span></li> <li><span class=button>B</span></li> <li><span class=button>C</span></li>
I have an html file that uses the span keyword in two different ways.
I have two span tags inside two divs inside a master div <div> <div>
I need to have a slightly different HTML element in IE7 than the rest,
Easy question, it is valid to have overlapping spans in html? Example: <span id=1>This
I have an HTML select list which, when an item is selected, must show
I have the following HTML: <ul> <li id=about><a href=#about class=goto_about>About us<span>who we are</span></a></li> <li
I have two <span> -tags with the same ID in different places om my
I have the following code: $(document).ready(function(){ $(.datepicker).each(function() { $(this).datepicker({ beforeShowDay: function(date){ return [$(this).parent().find(span.days).html(), ]

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.