例如:
我想添加target=_blank
任何 PDF 链接都在这个 css 类中"class="newWindow"
添加脚本之前
<div class="newWindow" >
<a href="pdf1.pdf">link text</a>
<a href="pdf2.pdf">link text</a>
</div>
添加脚本后
<div class="newWindow" >
<a href="Pdf1.pdf" target="_blank">link text</a>
<a href="Pdf2.pdf" target="_blank">link text</a>
</div>
请提供没有冲突的jquery代码。
Code
$(".newWindow a[href$='pdf']").attr('target','_blank');
:]
Preview:
http://jsbin.com/ojapo http://jsbin.com/ojapo
查看代码
http://jsbin.com/ojapo/edit http://jsbin.com/ojapo/edit
Note:
在 jsbin 示例中,我还添加了类.bl
,这样你就可以很容易地看到结果:]
无冲突模式:
jQuery.noConflict();
jQuery(".newWindow a[href$='pdf']").attr('target','_blank');
or
jQuery.noConflict();
jQuery(document).ready(function($){
$(".newWindow a[href$='pdf']").attr('target','_blank');
});
或者另一种方式,请看这里:http://docs.jquery.com/Using_jQuery_with_Other_Libraries http://docs.jquery.com/Using_jQuery_with_Other_Libraries
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)