【问题标题】:JQuery UI show('slide', {direction: right}, 500) not sliding, just showing [duplicate]JQuery UI show('slide', {direction: right}, 500) 不滑动,只显示 [重复]
【发布时间】:2013-05-12 04:31:04
【问题描述】:

试图最终让这个婴儿上床睡觉...(有关上下文/先前的尝试和讨论,请参阅 here 和 here)

我试图通过向左/向右滑动来隐藏一个元素,并通过从左侧或右侧滑入来显示一个元素:

$(oldBox).hide('slide',{direction:'right'},500);
$(newBox).show('slide',{direction:'right'},500);

实际情况是老元素隐藏不滑动,新元素显示不滑动。

HTML 的相关部分(相同的代码重复多次,只是 id 和名称发生了变化):

<div class="x" id="waistBox">
    <div class="measureCol measureColLeft">
        <span class="measureHeader">Waist</span>
        <div class="measureDescription">
            Surround your waist with the tape measure at the height
            you are most comfortable wearing your pants. Adjust the
            tape measure to your desired snugness, as your purchase
            waist will match this measurement exactly (e.g. 34.75
            inches).
        </div>
        <div class="measureValue">
            <input type="text" name="waist" value = "1" id="waistInput" class="editMeasureInfo"/>
            <i>inches</i>
        </div>
    </div>
    <div class="measureCol measureColRight">
        <div class="measureVideoContainer">
            <img src="../../images/Measure_Video.PNG" class="measureVideo" />
        </div>
    </div>
</div>

jQuery 函数:

function change_measurement_display(oldDisp, newDisp) {
    var oldBox = '#' + oldDisp + 'Box';
    var newBox = '#' + newDisp + 'Box';

    $(oldBox).hide('slide', {
        direction : 'right'
    }, 500);
    $(newBox).show('slide', {
        direction : 'right'
    }, 500); 


}

【问题讨论】:

  • 您能否发布相关代码或制作一个小提琴,然后让我们挖掘您的源代码会容易得多,这将随着时间的推移而改变,有助于答案与线程的未来读者保持相关:) 谢谢.
  • 嘿@FireCrakcer37,我没有制作/链接到小提琴的原因是,当小提琴设置为无换行时,该功能在小提琴上工作 - 在 中,但我不能让它在本机站点上工作。我链接的站点只是一个显示功能的静态测试站点。我会贴出相关代码。

标签: jquery jquery-ui


【解决方案1】:

您想使用“效果”而不是“隐藏”

$(oldBox).effect('slide', { direction: 'right', mode: 'show' }, 500);

$(newBox).effect('slide', { direction: 'right', mode: 'hide' }, 500);

【讨论】:

  • 试过了,没用 :(
  • 我不得不消除延迟,它对我来说很有效,500
  • 您可以在对象参数中添加duration:500作为选项。
  • @RTF 你是对的 - $(oldBox).effect('slide', {direction: 'right', duration: 1000});工作正常。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多