2016-02-26 80 views
0

我想用http://demos.jquerymobile.com/1.4.5/popup/创建一个弹出窗口。jQuery手机插件弹出支持

这里的jQuery的托管CDN承载的文件:https://jquerymobile.com/download/

这只要我来https://jsfiddle.net/hbaecklund/1zoj1pms/2/为什么它不工作?



这里就是我试图使用jQuery创建。

$("head").append ('<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" /><script src="http://code.jquery.com/jquery-1.11.1.min.js"></script><script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>'); 
$(".target").append('<a href="#popupCloseRight" data-rel="popup" class="ui-btn ui-corner-all ui-shadow ui-btn-inline">Right close button</a><div data-role="popup" id="popupCloseRight" class="ui-content" style="max-width:280px"><a href="#" data-rel="back" class="ui-btn ui-corner-all ui-shadow ui-btn-a ui-icon-delete ui-btn-icon-notext ui-btn-right">Close</a><p>I have a close button at the top right corner with simple HTML markup.</p></div>'); 
+0

在使用jQuery函数之前,您必须先加载jQuery.js。或者你可以使用Javascript插入它们。 http://plnkr.co/edit/cRuBsJF6HLEMvtJfPqua?p=preview – Omar

回答

1

在的jsfiddle你必须输入你的外部 “的CSS”,然后在 “外部资源”,在左侧菜单中的 “JS” 文件:

enter image description here

除此之外,的jsfiddle要求https而不是http。

做完之后,your code works

+0

非常感谢你! – Hbaecklund

+0

收到你的谢意让我非常高兴。 :-) – Lombas

1
<!-- Include meta tag to ensure proper rendering and touch zooming --> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 

    <!-- Include jQuery Mobile stylesheets --> 
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css"> 

    <!-- Include the jQuery library --> 
    <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script> 
    <script> 
    $(document).bind('mobileinit',function(){ 
     $.mobile.changePage.defaults.changeHash = false; 
     $.mobile.hashListeningEnabled = false; 
     $.mobile.pushStateEnabled = false; 
    }); 
    </script> 

    <!-- Include the jQuery Mobile library --> 
    <script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script> 

</head> 
    <body> 
    <a href="#popupBasic" data-rel="popup" class="ui-btn ui-corner-all ui-shadow ui-btn-inline" id="pop" data-transition="pop">Basic Popup</a> 
     <div data-role="popup" id="popupBasic"> 
     <p>pop!!</p> 
     </div>