Minimize / Maximize div's with jQuery

前端 未结 2 1077
既然无缘
既然无缘 2021-01-04 13:10

I basically want to minimise some div\'s . Instead of using \"-\" and \"+\", I want to use some symbols (from font-awesome) to minimise and maximise the div\'s.

My

2条回答
  •  没有蜡笔的小新
    2021-01-04 13:37

    You can use CSS to apply the symbols/icons as background images, then just have a separate CSS class which contains the other icons which and then just toggle this class in the element.

    CSS

    .btn-minimize {
      background-image: url("/path/to/icon");
    }
    
    .maximize {
      background-image: url("/path/to/another/icon");
    }
    

    jQuery

    $(".btn-minimize").click(function() {
      $(this).toggleClass("maximize");
      $(".widget-content").slideToggle();
    });
    

提交回复
热议问题