Chrome扩展内容脚本中的JQueryUI

时间:2015-07-10 07:30:46

标签: jquery-ui google-chrome-extension

在清单中放入jquery-ui(css和js)和jquery后,我可以使用jq选择器($),但是jquery-ui似乎无法访问。例如,我试图在内容脚本(content_script.js)中插入可调整大小的div:

var $div = document.createElement('div');
$div.id = 'divId';
$div.innerHTML = 'inner html';
$("body").append($div);//works without error
$("#divId").css("background-color","yellow");//works
//doesn't give resizable handles, however works in a regular html file:
$("#divId").resizable();
//however this also has issue:
document.getElementById("divId").style.resize = "both";

清单:

"css":["jquery-ui.css"],
"js": ["jquery-ui.js","jquery.js","content_script.js"]

1 个答案:

答案 0 :(得分:4)

错误的加载顺序 - jquery-ui希望首先加载jquery

"js": ["jquery.js", "jquery-ui.js", "content_script.js"]