Home > Web Front-end > JS Tutorial > body text

Thermometer animation effect based on Jquery_jquery

WBOY
Release: 2016-05-16 18:24:55
Original
1413 people have browsed it

The design drawing is as follows:
Thermometer animation effect based on Jquery_jquery
1.xhml

Copy code The code is as follows:




0℃








2.css
Copy code 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

Copy code The code is as follows:

$(document).ready(function(){
$("#hot").fadeTo(0,0);//Initial Transparency is 0;
$('#num').click(function(){this.select();})
$('#Risk').click(function(){
inputvalue =$('#num').val();//val() gets the value of the input element, and you can also use attr("value") to get it;
var inputnum=parseInt(inputvalue);
if($('#num').val().search("^-?\d $") != 0){
alert("Please enter an integer from 0 to 100!");
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('slow',Columnhe);
//The effect of replacing html with text here is the same;
});
});

Copy the code one by one to the corresponding location on the page, and then remember to call The jquery framework has limited display conditions, so the effect is different from the design drawing, but the implementation principle is the same. Welcome everyone to communicate!
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!