1

i load second.html into #divcontainer@first.html, and i want to load third.html to #divcontainer@first.html using the button within the second.html, while unload the second.html

i succeed loading the second html into first html using load().

i have tried using this in the second.html:

    $("#button").click(function () {
    $("#divcontainer".top.parent.document).unload("second.html");
    $("#divcontainer".top.parent.document).load("third.html");
    });

but doesnt work.

https://i.stack.imgur.com/kmB3U.jpg "structure"

1 Answers1

0

As the elements are dynamically loaded then you have to use event delegation:

$('#divcontainer').on('click', '#button' function () {
   $(this).parent().load('third.html');
});

and you don't need to unload anything as it will replace the existing content.

Jai
  • 74,255
  • 12
  • 74
  • 103