如何使用Jquery动态加载锚标签 [英] How to load anchor tags dynamically using Jquery
本文介绍了如何使用Jquery动态加载锚标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是jQuery的新手。我的网站上有一个页面,其中包含10个锚标签以及嵌入PDF视图的iframe。如何使用Jquery动态加载各个URL的锚标签。我在xml文件中有URL列表。
Hi, I am very new to jQuery. I have a page on my site with 10 anchor tags alongside an iframe which is embedded for PDF view. How can I load the anchor tags with respective URL's dynamically using Jquery. I have the URL list in xml file.
<a class="ShowPDF1" href="URL to the PDF location" target="pdfframe"></a>
<iframe id="pdfframeID" name="pdfframe" height="650" width="900" frameborder="1"></iframe>
Any help would be greatly appreciated. Thanks
推荐答案
为你的主播分配和识别。
Assign and id to your anchor.
<a id="test" href="#"></a>
然后你可以尝试得到元素
Then you can try to get the element
var anchorHref =
(< span class =code-keyword> this )。attr(' href') ;
// 在您的情况下可能是iframe。所以你可能需要调整它或者用jquery来获取它
window .open(url,' _ blank');
(this).attr('href'); //in your case it might the iframe. So you may need to adapt it or get it with jquery as well window.open(url, '_blank');
这篇关于如何使用Jquery动态加载锚标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文