简体   繁体   English

jQuery无法在弹出窗口中工作

[英]jquery not working in popup window

I have code to submit form in jquery but all these need to happen in a popup window. 我有代码在jquery中提交表单,但是所有这些都需要在弹出窗口中进行。

I have minimized my script to the simplest form without the ajax calls and other for readability purpose, I want to know how to achieve a simple jquery code initiated in a popup window many thanks 我已将脚本最小化为最简单的形式,而没有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>'); } }); 
 <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> 

But I always get the following error: 但是我总是收到以下错误:

VM23221:1 Uncaught ReferenceError: $ is not defined VM23221:1 Uncaught ReferenceError:未定义$

I have tried no-conflict and loading full script from external server. 我尝试了无冲突并从外部服务器加载完整脚本。

使用Jquery之前,请确保已加载它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM