我有代码在jquery中提交表单,但所有这些都需要在弹出窗口中进行。
我已经将我的脚本最小化为最简单的形式,没有ajax调用和其他用于可读性目的,我想知道如何实现在弹出窗口中启动的简单jquery代码非常感谢
$("button").on('click', function(event) {
var id = $(this).attr("id");
if (id == "go") {
var w = window.open("", "popupWindow", "width=550, height=550, scrollbars=no");
var $w = $(w.document.body);
$w.html('<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"><\/scr' + 'ipt><script>$.noConflict(); jQuery( document ).ready(function( $ ) {$("body").show("fast", function() {$(".pal").focusin(function(event) {/* Act on the event */ $(".er").remove(); $(this).css({backgroundColor: "#0b4cb9", boxShadow: "0 2px 2px 0 rgba(0,0,0,0.14), 0 3px 1px -2px rgba(0,0,0,0.12), 0 1px 5px 0 rgba(0,0,0,0.2)"}); }); }); });<\/scr' + 'ipt>');
}
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button style="padding:10px 40px;" id="go">go</button>
&#13;
但我总是收到以下错误:
VM23221:1未捕获的ReferenceError:$未定义
我尝试过无冲突并从外部服务器加载完整脚本。
答案 0 :(得分:0)
确保在使用之前加载Jquery。