jQuery隐藏并显示带有加号和减号图标的切换div

前端之家收集整理的这篇文章主要介绍了jQuery隐藏并显示带有加号和减号图标的切换div前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有代码为展示工作,并隐藏div.当显示和隐藏活动时,我将如何添加两个不同的图标作为精灵图像?

例如:显示我的图标,然后是一个隐藏我的图标.

这是代码,我有:
http://jsfiddle.net/BLkpG/

$(document).ready(function(){
   $(".slidingDiv").hide();
   $(".show_hide").show();

    $('.show_hide').click(function(){
    $(".slidingDiv").slideToggle();
  });
});

切换到或 – 时,需要将图像更改为上述内容.

谢谢

解决方法

尝试这样的东西

jQuery的

$(document).ready(function(){

   $(".slidingDiv").hide();
   $(".show_hide").show();

   $('.show_hide').toggle(function(){
       $("#plus").text("-");
       $(".slidingDiv").slideDown();

   },function(){
       $("#plus").text("+");
       $(".slidingDiv").slideUp();
   });

});

HTML

<a href="#" class="show_hide" id="plus">+</a>

<div class="slidingDiv" style="display: block;">
    Check out the updated jQuery plugin for doing this: <a href="http://papermashup.com/jquery-show-hide-plugin/" class="show_hide" target="_blank" style="display: inline;">jQuery Show / Hide Plugin</a>
</div>

CSS

.show_hide {
    display:none;
}
.a{
    font: 2em Arial;
    text-decoration: none
}

DEMO

在这里查看本教程http://www.webstutorial.com/simple-jquery-toggle-tutorial-css-jquery-slide-toggle/jquery

DEMO

原文链接:https://www.f2er.com/jquery/179623.html

猜你在找的jQuery相关文章