我想以与jQuerify书签相同的方式使用表排序插件。
我应该如何自己去做这件事,或者它可以在其他地方使用?
发布于 2011-01-11 10:03:05
将这段代码放在你的bookmarklet代码的开头:
var s=window.document.createElement('script'); s.setAttribute('src','http://code.jquery.com/jquery-latest.min.js'); window.document.body.appendChild(s);这基本上包括jQuery库。
编辑:此外,如果这仅供个人使用,您可能希望在计算机上保留jQuery的本地副本,并将脚本的目标指向该副本。未经许可就使用另一台服务器的资源是很不体贴的。
Edit2:对不起,我误解了你的问题。以下是修改后的代码:
javascript:(function(){
var s=window.document.createElement('script');
s.setAttribute('src','http://code.jquery.com/jquery-latest.min.js');
window.document.body.appendChild(s);
var s2=window.document.createElement('script');
s2.setAttribute('src','http://tablesorter.com/jquery.tablesorter.min.js');
window.document.body.appendChild(s2);
$('table').tablesorter();
})();我把它分成不同的行,这样更容易阅读。这是一个精简的版本:
javascript:(function(){var s=window.document.createElement('script');s.setAttribute('src','http://code.jquery.com/jquery-latest.min.js');window.document.body.appendChild(s);var s2=window.document.createElement('script');s2.setAttribute('src','http://tablesorter.com/jquery.tablesorter.min.js');window.document.body.appendChild(s2);$('table').tablesorter();})();https://stackoverflow.com/questions/4653298
复制相似问题