javascript - How can I display a variable content in HTML? -
it's 9th day of learning how code! #excitement
let's have title
<h1 id="title">test </h1>
and have variable
<script type="text/javascript"> var content=$("#title).html(); </script>
how var content displayed in let's new paragraph? trying this:
<p id="test"> <p> <script type="text/javascript"> $("#test").html(content); </script>
thanks!
ps: i've seen things using "element.innerhtml", didn't seem fit problem, or didn't it. question asker didn't provide example.
simple way can this, see below code
$(document).ready(function(){ $("#test").text($(".title").html()); });
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script> <h1 class="title">test </h1> <p id="test"> <p>
Comments
Post a Comment