简体   繁体   中英

jquery not working in popup window

I have code to submit form in jquery but all these need to happen in a popup window.

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

 $("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

I have tried no-conflict and loading full script from external server.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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