Javascript 从onclick调用JQuery对话框
下面的HTML将显示一个带有2个按钮的页面。其中一个将以正常方式打开JQuery对话框,并且工作正常 另一个按钮是试图以非jquery函数的形式打开对话框,但它不起作用。我很担心第二个按钮不是应该怎么做的——但是出于我不想在这里解释的原因,我想知道这是否可行 我是jquery新手,所以我确信关于NT名称空间等的一些基本问题目前我还不完全了解。我已经尝试了很多方法,但都没有成功,现在我想咨询一下如何做到这一点。更一般的问题是关于“普通”javascript如何引用和操作JQuery函数 能做到吗Javascript 从onclick调用JQuery对话框,javascript,jquery,Javascript,Jquery,下面的HTML将显示一个带有2个按钮的页面。其中一个将以正常方式打开JQuery对话框,并且工作正常 另一个按钮是试图以非jquery函数的形式打开对话框,但它不起作用。我很担心第二个按钮不是应该怎么做的——但是出于我不想在这里解释的原因,我想知道这是否可行 我是jquery新手,所以我确信关于NT名称空间等的一些基本问题目前我还不完全了解。我已经尝试了很多方法,但都没有成功,现在我想咨询一下如何做到这一点。更一般的问题是关于“普通”javascript如何引用和操作JQuery函数 能做到吗
<!doctype html>
<html>
<head>
<title>My Dialog demo</title>
<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/themes/base/jquery-ui.css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/jquery-ui.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
var $dialog = $('<div></div>')
.html('My Dialog Demo...')
.dialog({
autoOpen: false,
title: 'My Dialog'
});
$('#Button1').click(function () {
$dialog.dialog('open');
return false; ////cancel eventbubbeling
});
});
function showDialog() {
$dialog.dialog('open');
return false //cancel eventbubbeling
}
</script>
</head>
<body>
<!-- JQuery autowired event-->
<button id="Button1">Open dialog (JQuery event wireup)</button>
<!-- Manual -->
<button id="Button2" onclick="showDialog();">Open (manual onClick event)</button>
</body>
</html>
我的对话演示
$(文档).ready(函数(){
变量$dialog=$('')
.html('我的对话框演示…')
.对话({
自动打开:错误,
标题:“我的对话”
});
$('#按钮1')。单击(函数(){
$dialog.dialog('open');
返回false;///cancel eventbubbeling
});
});
函数showDialog(){
$dialog.dialog('open');
返回false//cancel eventbubbeling
}
打开对话框(JQuery事件连接)
打开(手动单击事件)
像这样制作$dialog
全局
<script type="text/javascript">
var $dialog;
$(document).ready(function () {
$dialog = $('<div></div>')
.html('My Dialog Demo...')
.dialog({
autoOpen: false,
title: 'My Dialog'
});
$('#Button1').click(function () {
$dialog.dialog('open');
return false; ////cancel eventbubbeling
});
});
function showDialog() {
$dialog.dialog('open');
return false //cancel eventbubbeling
}
</script>
var$对话框;
$(文档).ready(函数(){
$dialog=$('')
.html('我的对话框演示…')
.对话({
自动打开:错误,
标题:“我的对话”
});
$('#按钮1')。单击(函数(){
$dialog.dialog('open');
返回false;///cancel eventbubbeling
});
});
函数showDialog(){
$dialog.dialog('open');
返回false//cancel eventbubbeling
}
像这样制作$dialog
全局
<script type="text/javascript">
var $dialog;
$(document).ready(function () {
$dialog = $('<div></div>')
.html('My Dialog Demo...')
.dialog({
autoOpen: false,
title: 'My Dialog'
});
$('#Button1').click(function () {
$dialog.dialog('open');
return false; ////cancel eventbubbeling
});
});
function showDialog() {
$dialog.dialog('open');
return false //cancel eventbubbeling
}
</script>
var$对话框;
$(文档).ready(函数(){
$dialog=$('')
.html('我的对话框演示…')
.对话({
自动打开:错误,
标题:“我的对话”
});
$('#按钮1')。单击(函数(){
$dialog.dialog('open');
返回false;///cancel eventbubbeling
});
});
函数showDialog(){
$dialog.dialog('open');
返回false//cancel eventbubbeling
}
应该考虑将jQuery升级到更当前的版本,你的版本已经很老了。只需将脚本标记的src从“1.3.2”更改为“1.7”,将jQuery UI更改为“1.8”。您遇到的一些代码可能包括更新的方法谢谢提示-可以!应该考虑把jQuery升级到更多的当前版本,你的版本已经相当老了。只需将脚本标记的src从“1.3.2”更改为“1.7”,将jQuery UI更改为“1.8”。您遇到的一些代码可能包括更新的方法谢谢提示-可以!