[英]jquery Ui dialog need to change the button click event
我正在使用jquery UI創建一個彈出窗口作為警報消息,單擊它以調用它並獲得另一個頁面時,我不需要單擊確定按鈕,有人可以幫助我嗎?
<html lang="en">
<head>
<meta charset="utf-8" />
<title>jQuery UI Dialog - Modal message</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<!--<link rel="stylesheet" href="/resources/demos/style.css" />!-->
<script>
$(function() {
$("#dialog-message").dialog({
modal : true,
buttons : {
enter : function() {
$(this).dialog("close");
}
}
});
});
</script>
</head>
<body>
<div id="dialog-message" title="WIN PRICES" style="width:300px; height:150px;">
<p>
<!--<span class="ui-icon ui-icon-circle-check" style="float: left; margin: 0 7px 50px 0;"></span>!-->
<span style ="float: left; margin:0 7px 50px 0;"><img src="b4l.jpg" width="77" height="53"></span>
<h3>byu for less</h3>
Shoping online <b>Need No Password</b>
<br>
Get your needs is our job.
</p>
<p>
<b>every week win a price</b>.
</p>
</div>
<p>
Sed vel diam id libero <a href="http://example.com">rutrum convallis</a>. Donec aliquet leo vel magna. Phasellus rhoncus faucibus ante. Etiam bibendum, enim faucibus aliquet rhoncus, arcu felis ultricies neque, sit amet auctor elit eros a lectus.
</p>
</body>
</html>
您可以創建一個自定義警報框,以對其進行自定義以滿足您的需求。
在這里看看,因為這將幫助您選擇更適合自己的東西。
PS:您也可以嘗試以下方法。
的HTML
<input type="button" onclick="confirmation()" value="Want to go to google?">
JS
function confirmation() {
var answer = confirm("Want to go to google?");
if (answer){
alert("Bye bye!");
window.location = "http://www.google.com/";
}
else{
alert("Thanks for sticking around!");
}
}
不確定“呼叫並獲得另一個頁面”是什么意思?
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css" />
<script type="text/javascript">
$(document).ready(function() {
$( "#dialog-message" ).dialog({
modal: true,
buttons: {
enter: function() {
$( this ).dialog( "close" );
window.location.href='http://google.com';
}
}
});
}); //END $(document).ready()
</script>
</head>
<body>
<div id="dialog-message">
<h1>Example Dialog</h1>
<img src="http://placehold.it/150x150" width="150" height="150"/>
First Name: <input type="text" id="fname"><br />
Last Name: <input type="text" id="lname"><br />
</div>
</body>
</html>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.