Jquery load doesn't work

前端 未结 4 1241
一生所求
一生所求 2021-01-19 04:13

The jquery load in the below code doesn\'t work. What I\'m missing here?





        
4条回答
  •  心在旅途
    2021-01-19 04:43

    Script Execution

    When calling .load() using a URL without a suffixed selector expression, the content is passed to .html() prior to scripts being removed. This executes the script blocks before they are discarded. If .load() is called with a selector expression appended to the URL, however, the scripts are stripped out prior to the DOM being updated, and thus are not executed. An example of both cases can be seen below:

    Here, any JavaScript loaded into #a as a part of the document will successfully execute.

    $('#a').load('article.html');
    

    However, in the following case, script blocks in the document being loaded into #b are stripped out and not executed:

    $('#b').load('article.html #target');
    

    Source: jQuery.com

提交回复
热议问题