在清单中放入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"]
答案 0 :(得分:4)
错误的加载顺序 - jquery-ui
希望首先加载jquery
。
"js": ["jquery.js", "jquery-ui.js", "content_script.js"]