To achieve the click of the down arrow to turn the arrow back and forth switch two ways to "recommend" _jquery

Source: Internet
Author: User

These are the two types of common knowledge I know.

The first one: to illustrate that I used the Fontawesome font, the first to go to the official website to download to use

<span class= ' btn btn-more ' >
  <i class= ' fa fa-angle-down ' ></i>
  <i class= ' FA fa-angle-up Hidden ' ></i>
</span>

I use the bootstrap, so the hidden is self-contained, the above initial state is the down arrow Angle-down is displayed, and then the upper arrow angle-up is hidden.

On JS code :

  $ ('. Btn-more '). Click (function (EV) {
  
    $ (this). Children ('. Fa-angle-down '). Toggleclass (' hidden ');
    $ (this). Children ('. fa-angle-up '). Toggleclass (' hidden ');
  })

In this way, the up and down arrows can be switched back and forth, in general, when the content is displayed may be used

The second approach is that the HTML code

<li class= "sub-item" >
  <a href= "javascript:;" >             
  <span class= "Arrow" ></span>
  </a>
</li>

CSS Code

. arrow:before {
  float:right;
  width:20px;
  Text-align:center;
  Display:inline;
  font-size:16px;
  Font-family:fontawesome;
  Height:auto;
  Content: "\f104";
  font-weight:300;
  Text-shadow:none;
  Position:absolute;
  top:4px;
  right:14px;
  Color: #990;
arrow.open:before{
content: ' \f107 ';
}

JS Code is

$ ('. Nav-item>a '). Click (function () {
$ (this). Children ('. Arrow '). Toggleclass (' Open ')
})

The second approach is primarily to overwrite the previous content by adding a class, which is also the Fonawesome font.

The above is the entire content of this article, I hope the content of this article for everyone's study or work can bring some help, but also hope that a lot of support cloud Habitat community!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.