0

次の小さなコード ブロックを見てください。

<html>
<head>
<script type="text/javascript" src="http://mydomain.com/jquery-min.js"></script>
<script id="the-script" type="text/javascript" src="http://otherdomain.com/js/some-script.js"></script>
<script>
   /*
     console.log(jQuery("#the-script").some-property);
   */
</script>
</head>
<body>
</body>
</html>

jQuery("#the-script").some-propertyスクリプトのソース コードをテキスト (文字列) として取得できるプロパティを求めています。そのためのプロパティはありますか?

4

1 に答える 1

0

そのファイルのコンテンツのリクエストを送信ajaxして、それで何でもすることができます。これがどのように機能するかを示すために、jQuery ソース コードを span 要素にロードするフィドルを作成しました。

http://jsfiddle.net/Z7X6Z/

于 2013-06-05T20:50:08.143 に答える