最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - JQuery Function import html from external source - Stack Overflow

programmeradmin1浏览0评论

I have this JQuery function:

function addSomeHTML()
            {
                  $("#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

I have this JQuery function:

function addSomeHTML()
            {
                  $("#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

Share Improve this question asked Apr 17, 2011 at 22:23 Satch3000Satch3000 49.5k90 gold badges225 silver badges349 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

Use the AJAX load() method.

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

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

发布评论

评论列表(0)

  1. 暂无评论