2015-07-10 128 views
3

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

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"] 

回答

4

错误的加载顺序 - jquery-ui预计jquery首先被加载。

"js": ["jquery.js", "jquery-ui.js", "content_script.js"] 
相关问题