Jquery-based thermometer animation effect _ jquery

Source: Internet
Author: User
Tags html to text
Copy the code one by one to the corresponding location on the page, and then remember to call the jquery framework. The display conditions are limited, so the effect is different from the design drawing, but the implementation principle is the same. You are welcome to talk more! The design diagram is as follows:

1. xhml

The Code is as follows:





0 ℃









2. css

The Code is as follows:


# Num {color: #999 ;}
# Mometer {position: relative; height: 100px; width: 15px; background-color: # CCC; margin: 50px ;}
Span {position: absolute; display: block; bottom: 0px; width: 40px ;}
# Hgheader {height: 15px; line-height: 15px; color: # FF0000; font-size: 14px; font-family: Arial, Helvetica, sans-serif;
Border-bottom: # f00 1px solid; left:-40px; position: relative ;}
# Hg {height: 0px; font-size: 0px; background-color: # C00; width: 15px ;}
# Hot {height: 100px; width: 15px; background-color: # FF0; position: absolute; top: 0; left: 0 ;}


3. js

The Code is as follows:


$ (Document). ready (function (){
$ ("# Hot"). fadeTo (0, 0); // The initial transparency is 0;
$ ('# Num'). click (function () {this. select ();})
$ ('# Risk'). click (function (){
Inputvalue = $ ('# num'). val (); // val () obtains the value of the input element. In addition, it can be obtained using attr ("value;
Var inputnum = parseInt (inputvalue );
If ($ ('# num'). val (). search ("^ -? \ D + $ ")! = 0 ){
Alert ("enter an integer between 0 and! ");
Return false;
} Else {
$ ("# Hgheader" ).html (inputvalue + "℃ ");
If (inputnum> = 100 ){
Inputnum= 100;
$ ('# Num'). val (100)
$ ("# Hgheader" ).html (100 + "℃ ");
} Else if (inputnum <= 0 ){
Inputnum = 0;
$ ('# Num'). val (0)
$ ("# Hgheader" ).html (0 + "℃ ");
}
}
Var Columnhe = inputnum/100;
$ ("# Hg"). animate ({height: inputnum}, 'show ');
$ ("# Hot"). fadeTo ('low', Columnhe );
// Here, the effect of changing html to text is the same;
});
});


Copy the code one by one to the corresponding location on the page, and then remember to call the jquery framework. The display conditions are limited, so the effect is different from the design drawing, but the implementation principle is the same. You are welcome to talk more!
Related Article

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.