jquery - 我可以在 JQuerify 等书签中使用 JQuery 插件吗

标签 jquery jquery-plugins

我想以与 jQuerify 书签相同的方式使用 tablesorter 插件。

我应该如何自己做这件事,或者可以在某个地方找到它吗?

最佳答案

将其放在小书签代码的开头:

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();})();

关于jquery - 我可以在 JQuerify 等书签中使用 JQuery 插件吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4653298/

相关文章:

javascript - jquery focus() 只关注第一个文本输入

jquery - 如何设置事件的 jQuery 菜单项

javascript - jquery on click 不适用于动态添加的项目

jquery-plugins - jQuery gzoom 插件不起作用

滚动区域中的 jQuery 为 'Jump Down',带有按钮,而不是滚动条

jquery - 解决 jQuery/jqGrid 不显示问题

jquery-plugins - 调试 jQuery 插件以在两个相等的列中显示动态列表

jQuery 从 url 哈希中查找属性

javascript - KnockoutJs 中 UI 刷新后是否有回调?

javascript - 点击按钮后 jquery 谷歌地图不会重新加载