代码之家  ›  专栏  ›  技术社区  ›  Andrew

jQuery:如何同时显示元素和使用高亮效果?

  •  6
  • Andrew  · 技术社区  · 14 年前

    <div id="a">content</div>
    <div id="b" style="display:none">different content</div>
    

    当我单击当前显示的 div ,我想把它藏起来给另一个看。这很容易做到:

    $('#a').hide();
    $('#b').show();
    

    effect("highlight") ,但我不能让它工作。我如何做到这一点?

    1 回复  |  直到 14 年前
        1
  •  5
  •   user113716    14 年前

    鉴于此,您可能只需要加载jQueryUI。要使这种效果发挥作用是必须的。

    http://jqueryui.com/demos/effect/

    举个例子: http://jsfiddle.net/r6pKn/

    <div id="div1">content</div>
    <div id="div2" style="display:none">different content</div>​
    

    jQuery查询

    $('#div1').click(function() {
       $(this).hide();
       $('#div2').show().effect('highlight');
    });​