开发者

JQuery Function import html from external source

开发者 https://www.devze.com 2023-02-26 01:34 出处:网络
I have this JQuery function: function addSomeHTML() 开发者_如何学C{ $(\"#mysection\").html(\"<div id=\'myid\'>some content here</div>\");

I have this JQuery function:

function addSomeHTML()
        开发者_如何学C    {
                  $("#mysection").html("<div id='myid'>some content here</div>");
            }

I basically need this part: <div id='myid'>some content here</div> to be read from an external file.

Can anyone help please?

Thanks


Use the AJAX load() method.

$('#mysection').load('yourfile.html');

Of course the URL can also point to a PHP script etc.

0

精彩评论

暂无评论...
验证码 换一张
取 消