Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在JQuery中合并两个函数_Jquery - Fatal编程技术网

如何在JQuery中合并两个函数

如何在JQuery中合并两个函数,jquery,Jquery,我正在成功打开JQuery对话框。我的第一个JQuery函数打开对话框,第二个JQuery函数将对话框位置设置为顶部。我想合并这两个函数,请参见我的以下代码:- $(function () { $("#modal-registration").dialog({ autoOpen: false, height: 400, width: 380, model: true }); $('#modal-registr

我正在成功打开JQuery对话框。我的第一个JQuery函数打开对话框,第二个JQuery函数将对话框位置设置为顶部。我想合并这两个函数,请参见我的以下代码:-

$(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" );
});