我一直在玩这个jquery wiki插件。但是我坚持使用我想要完成的特定功能。有没有办法过滤返回的数据,只显示粗体或<b>
标签中的项目。
我有以下代码:
<body>
<h1>Wikiblurb</h1>
<div id="article"></div>
<script src="js/jquery.wikiblurb.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#article').wikiblurb();
});
</script>
</body>
.js文件的主要定制是:
var defaults = $.extend({
wikiURL: "http://en.wikipedia.org/",
apiPath: 'w',
section: 2,
page: 'List of reportedly haunted locations',
removeLinks: true,
type: 'all',
customSelector: '',
}, options);
之前有没有人使用过这个插件,或者指出了我如何只显示返回的位置在<b>
标签内的正确方向。
Jsfiddle:http://jsfiddle.net/xvubbo0s/
参考目的页:http://en.wikipedia.org/wiki/List_of_reportedly_haunted_locations(我只想返回澳大利亚标题下的链接文本)
该插件供参考:
https://github.com/9bitStudios/wikiblurb
答案 0 :(得分:1)
从插件引用看来,设置type: 'custom'
和customSelector: 'b'
似乎可以满足您的要求。
我创建了这个插件的一个fork,并为它添加了一个filterSelector来完成你要求的最后一个项目。 You can find the forked repository here
在设置中添加filterSelector: "a:contains('^')"