2.css
#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
$(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!