JavaScript无法在JQuery Load中工作 [英] JavaScript not working in JQuery Load
本文介绍了JavaScript无法在JQuery Load中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望使用 JavaScript 显示代码,然后使用jQuery
load加载它.
I wan to display a code with JavaScript then load it using jQuery
load.
这是我的代码:
<div class="noti"><span name="creator">::creator::</span></div>
<script type="text/javascript"> creators=document.getElementsByName('creator'); for(i=0;i<creators.length;i++){creator=document.getElementsByName('creator')[i].innerHTML; :userstats:d=ru,o=dl,s=1,l=50::if(creator=='%name%'){document.getElementsByName('avatar')[i].innerHTML='<a href="%urlprofile%"><img src="%urlpicture%" width="40" height="43" style="background: url(http://wapkaimage.com/400207/400207380_d4c2093a7f.PNG);" width: 40; height: 43;"/></a>';}:: :/userstats:}</script>
然后在另一个网址中加载:
Then in another url, load with this :
<div class="title">NOTIFICATION</div><div id="noti">Loading notification...</div>
<script type="text/javascript"> $('#noti').load('/popup_0.xhtml .noti',function(data){$(this).find('.noti').css({"width":"96%","margin":"auto"}); }); </script>
问题是,跨度名称创建器的结果未显示在JQuery加载中,但显示在第一个url
中.
The problem is the result of span name creator is not displayed in the JQuery load but it displays in the 1st url
.
推荐答案
这是因为您的JavaScript 所做的更改不会影响源/原始文件popup_0.xhtml
,但仍仅影响DOM.当load()
函数获取源文件中的代码时,将其加载到浏览器中.
That because the changes made by your javascript doesn't affect source/original file popup_0.xhtml
, but still affected just the DOM loaded in the browser, when the load()
function get the code inside the source file.
希望这会有所帮助.
这篇关于JavaScript无法在JQuery Load中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文