JQuery Sliding divs和更改按钮

时间:2018-03-07 14:51:05

标签: jquery html slidetoggle

我有一个页脚幻灯片切换功能,我想更改按钮。向上按钮,向下按钮。

请阅读代码,您将知道,想要什么。

$(".footer").click(function() {

  $footer = $(this);
  //getting the prev element
  $content = $footer.prev();
  $button = $footer.find("td");
  //open up the content needed - toggle the slide- if visible, slide up, if not slidedown.
  $content.slideToggle(500, function() {
    //execute this after slideToggle is done
    //change text of header based on visibility of content div
    return $content.is(":visible") ? $button.attr("up", "down") : $button.attr("down", "up");
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<div class="infobar">
  <table class="content">
    content
  </table>
  <table class="footer">
    <td class="up" style=" padding-top: 7px; padding-bottom: 7px;">
    </td>
  </table>
</div>

演示:http://jsfiddle.net/HAQyK/1652/

我该如何解决?

1 个答案:

答案 0 :(得分:0)

我将其更改为toggleClass。我认为你的属性不会达到你想要的效果。测试时,请确保完成动画。

http://jsfiddle.net/HAQyK/1685/

&#13;
&#13;
:
&#13;
     eQTL188  eQTL193 eQTL178 eQTL179 eQTL238                      
[1,] 1.209    1.970   1.967   1.921   1.657
[2,] 1.953    1.903   1.994   1.992   1.474 
[3,] 1.953    1.993   1.994   1.992   1.473
[4,] 1.952    1.993   1.994   1.99    1.482
&#13;
$(".footer").click(function () {

    $footer = $(this);
    //getting the prev element
    $content = $footer.prev();
		$button = $footer.find("td");
    //open up the content needed - toggle the slide- if visible, slide up, if not slidedown.
    $content.slideToggle(500);
    $button.toggleClass("up down")
});
&#13;
&#13;
&#13;