最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

基于Jquery的温度计动画效果_jquery

来源:动视网 责编:小采 时间:2020-11-27 20:49:59
文档

基于Jquery的温度计动画效果_jquery

基于Jquery的温度计动画效果_jquery:设计图如下:1.xhml 代码如下: 0℃ 2.css 代码如下: #num{color:#999;} #mometer{position:relative; height:100px;width:15px;background-color:#CCC;margin:50px;} span{position:absolute
推荐度:
导读基于Jquery的温度计动画效果_jquery:设计图如下:1.xhml 代码如下: 0℃ 2.css 代码如下: #num{color:#999;} #mometer{position:relative; height:100px;width:15px;background-color:#CCC;margin:50px;} span{position:absolute


设计图如下:

1.xhml

代码如下:



0℃





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);//初始透明度为0;
$('#num').click(function(){this.select();})
$('#Risk').click(function(){
inputvalue=$('#num').val();//val()获取input元素的值,另外还可以用attr("value")来获取;
var inputnum=parseInt(inputvalue);
if($('#num').val().search("^-?\\d+$") != 0){
alert("请输入一个0-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);
//在这里把html换成text效果也是一样的;
});
});

将代码一一拷贝到页面相应的位置,然后记得调用jquery框架,展示条件有限,所以效果跟设计图有出入,但实现原理是一样的,欢迎大家多多交流!

文档

基于Jquery的温度计动画效果_jquery

基于Jquery的温度计动画效果_jquery:设计图如下:1.xhml 代码如下: 0℃ 2.css 代码如下: #num{color:#999;} #mometer{position:relative; height:100px;width:15px;background-color:#CCC;margin:50px;} span{position:absolute
推荐度:
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top