如何在JQuery中合并两个函数
我正在成功打开JQuery对话框。我的第一个JQuery函数打开对话框,第二个JQuery函数将对话框位置设置为顶部。我想合并这两个函数,请参见我的以下代码:-如何在JQuery中合并两个函数,jquery,Jquery,我正在成功打开JQuery对话框。我的第一个JQuery函数打开对话框,第二个JQuery函数将对话框位置设置为顶部。我想合并这两个函数,请参见我的以下代码:- $(function () { $("#modal-registration").dialog({ autoOpen: false, height: 400, width: 380, model: true }); $('#modal-registr
$(function () {
$("#modal-registration").dialog({
autoOpen: false,
height: 400,
width: 380,
model: true
});
$('#modal-registration').dialog({ position: 'top' });
});
在上面的代码中,如何合并这两个函数,如
$(“#模式注册”).dialog({autoOpen:false,et:cetera})
和$('#模式注册').dialog({position:'top'})代码>彼此之间?,谢谢。您能不能在第一次对话框调用中插入position属性?像
$("#modal-registration").dialog({
autoOpen: false,
height: 400,
width: 380,
model: true,
position: 'top'
});
为什么不使用单个命令?
HTML
根据您的小提琴链接,将[0,0]更改为所需的x,y坐标,您可以执行以下操作:
$( "#dialog" ).dialog({
autoOpen: false,
height: 400,
width: 380,
model: true,
position : [0,0] //mention the attribute here itself
});
$( "#opener" ).click(function() {
$( "#dialog" ).dialog( "open" );
});
工作正常。$('dialog')。dialog('option','position',[0,0]);请看我的代码,我有两个函数,现在如何合并它们?谢谢$(文档).ready(函数(){$(“#模式注册”).dialog({show:“幻灯片”),模态:true,自动打开:false,高度:400,宽度:380,位置:'top',溢出:'hidden'});$('#模态注册').css('overflow','hidden'));请看我的代码,其中我有两个函数,现在我如何合并它们?谢谢$(文档)。准备(函数(){$(“#模式注册”)。对话框({显示:“幻灯片”,模式:真,自动打开:假,高度:400,宽度:380,位置:'top',溢出:'hidden');$('#模式注册')。css('overflow','hidden');$(“#模式注册”)。对话框({autoOpen:true,高度:400,宽度:380,型号:true,位置:'top'}).css('overflow','hidden'))
<button id="opener">open the dialog</button>
<div id="dialog" title="Dialog Title">I'm a dialog</div>
$('#dialog').dialog( 'option', 'position', [0, 0] );
$( "#dialog" ).dialog({
autoOpen: false,
height: 400,
width: 380,
model: true,
position : [0,0] //mention the attribute here itself
});
$( "#opener" ).click(function() {
$( "#dialog" ).dialog( "open" );
});