douling8772 2013-11-13 13:18
浏览 18
已采纳

jquery幻灯片效果隐藏完整页面

I m using this function for loading content dynamically depending on the item chosen from a dropdown. Here's my code:

<html>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" ></script>
<script type="text/javascript">
$(function() {
    $('.group').hide();
    $('#div1').show();
    $('#stype').change(function() {
        var val = $(this).val();
        if (val) {
            $('div:not(#div' + val + ')').slideUp();
            $('#div' + val).slideDown();
        } else {
            $('div').slideDown();
        }
    });
});
</script>
<form action="a.php" method="post">

  Select:
  <select name="stype" id="stype">
    <option value="1">op1</option>
    <option value="2">op2</option>
    <option value="3">op3</option>
    <option value="4">op4</option>
  </select>
<br><br>

<div id="div1" class="group">
This is div 1.
</div>

<div id="div2" class="group">
This is div 2.
</div>

<div id="div3" class="group">
This is div 3.
</div>

<div id="div4" class="group">
This is div 4.
</div>

<input type="submit" name="submit" value=" Submit " />
</form>
</html>

This works perfectly well when I run this on a plain php file. But when I m trying to put this up on my website, and display it as content there, whenever I make a selection from dropdown, the complete page of website slides up and is hidden. (header, breadcrumb, footer, sidebar and stuff)

How to fix this problem?

  • 写回答

3条回答 默认 最新

  • douliang2935 2013-11-13 13:20
    关注

    Have you tried replacing

    $('div:not(#div' + val + ')').slideUp();

    With

    $('.group').slideUp();

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥30 vmware exsi重置后登不上
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?
  • ¥15 电磁场的matlab仿真
  • ¥15 mars2d在vue3中的引入问题
  • ¥50 h5唤醒支付宝并跳转至向小荷包转账界面