0

I am trying to create an expand on click feature on my website. When the user clicks on the button, something is displayed.

I know I can use JS to make the div show up, but my HTML code is long, so I don't want to copy the entire thing there. I know I can also use the tag, but I don't want my page to refresh.

 function findPressure() {
  var ifrm = document.createElement("iframe");
  ifrm.setAttribute("src","/Users/lunapark/Documents/antoine_equation/antoine_pressure.html");
  document.body.appendChild(ifrm);
 }
  <div class="col-md-9">
    <button onClick="findPressure()">Solve for Pressure</button>
    <button onClick="findTemp()">Solve for Temperature</button>
  </div>

As you can see here, I used iframe, which I am not in favor of. Is there some way I can link the existing HTML to my main HTML and not have it refresh on a web page?

Jaydeep
  • 1,686
  • 1
  • 16
  • 29
Luna Park
  • 11
  • 1

1 Answers1

0

Lots of ways of doing this - upgrade to Vue.js for example. Or jQuery load() is pretty good for this kind of thing too. https://api.jquery.com/load/

dijipiji
  • 3,063
  • 1
  • 26
  • 21