簡體   English   中英

jQuery UI對話框內部html不顯示

[英]Jquery UI dialog inner html not showing

我想在對話框中插入一個登錄表單。 現在顯示對話框,但是沒有表單! 有什么幫助嗎? 我在該網站上搜索了google和其他帖子,但沒有找到答案!

這是代碼:

 $('.dia').attr('title', 'LOGIN').text('Login to eWarsha').dialog({ autoOpen: false, modal: true, draggable: false, resizable: false, width: 600, height: 400 }); $('#cl').click(function() { $('.dia').dialog("open"); }); 
 <html lang="en"> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css" /> <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script> </head> <body> <input type="submit" id="cl"> <div class="dia"> <form class="dia login-form-dia" method="post"> <input type="text" id="si" name="leamil" placeholder="Email" maxlength="16"> <input type="text" id="si" name="lpassword" placeholder="Password"> <input type="submit" name="login" value="LOGIN"> </form> </div> </body> </html> 

這是因為調用.text()方法時要替換.dia元素的內容:

$('.dia').attr('title', 'LOGIN').text('Login to eWarsha').dialog({ ... });

似乎您寧願使用以下內容代替該文本:

$('.dia').attr('title', 'LOGIN').prepend('<h2>Login to eWarsha</h2>').dialog({ ... });

..您可以只在HTML中指定title屬性,然后在其中添加所需的文本,而不是在其前面添加:

 var $dialog = $('.dia').dialog({ autoOpen: false, modal: true, draggable: false, resizable: false, width: 600, height: 400 }); $('#cl').click(function() { $dialog.dialog("open"); }); 
 <html lang="en"> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css" /> <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script> </head> <body> <input type="submit" id="cl"> <div class="dia" title="LOGIN"> <h2>Login to eWarsha</h2> <form class="login-form-dia" method="post"> <input type="text" id="si" name="leamil" placeholder="Email" maxlength="16"> <input type="text" id="si" name="lpassword" placeholder="Password"> <input type="submit" name="login" value="LOGIN"> </form> </div> </body> </html> 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM