Mushtaq Ali Mushtaq Ali - 20 days ago 6
jQuery Question

Adding html file to div tag jquery

I am trying to add html page to

<div>
tag using jQuery. I tried using load, get function but that did not work. Any advice how this can work?

I am learning and working on
turn.js
with just some basic knowledge of jQuery, please advise.

I am using jQuery 3.1

<div id="flipbook">
<div class="hard"> Turn.Js </div>
<div class="hard"></div>
<div id="page1"> </div>
<div> Page 2 </div>
<div> Page 3 </div>
<div> Page 4 </div>
<div class="hard"></div>
<div class="hard"></div>
</div>

<script type="text/javascript">
$("#flipbook").turn({
width: 400,
height: 300,
autoCenter: true
});

$(function () {
$.get("page1.html", function(data) {
$("#page1").append(data);
});
});
</script>

Answer

Assuming you are getting data back from page1.html, try:

$.get("page1.html", function(data) {
    $("#page1").html(data);
});
Comments