ホームページ  >  記事  >  ウェブフロントエンド  >  jquery はクローズ可能なカウントダウン広告の特殊効果を実装します code_jquery

jquery はクローズ可能なカウントダウン広告の特殊効果を実装します code_jquery

WBOY
WBOYオリジナル
2016-05-16 15:40:571168ブラウズ

この記事の例では、jquery を使用したクローズ可能なカウントダウン広告の特殊効果コードの実装について説明します。皆さんの参考に共有してください。詳細は以下の通りです。

これは、動画の再生時に最初に表示されるものと同様のカウントダウン広告です。右上隅に閉じるボタンが付いた小さな JS 広告コードです。カウントダウンの残り時間が左上隅に表示されます。jQuery コードを実行します。CSS と HTML を組み合わせた Web ページの特殊効果は、ポータル Web サイトからコンパイルされています。皆さんも気に入っていただければ幸いです。

ランニングエフェクトのスクリーンショットを見てみましょう:

オンライン デモのアドレスは次のとおりです:

http://demo.jb51.net/js/2015/jquery-close-time-adv-style-codes/

具体的なコードは次のとおりです:

<!DOCTYPE html>
<html>
<head>
<meta charset="gb2312">
<title>js贴片倒计时代码</title>
<style>
*{padding:0;margin:0; font-size:12px;}
ol,ul,li{list-style:none}
img{border:none}
.box{ width:564px; height:361px; margin:20px auto; position:relative; display:none;}
.ad_time{ width:554px; height:351px; background:#000; filter:alpha(opacity=50);-moz-opacity:0.5;opacity: 0.5; padding:5px; position:absolute; top:0; left:0; color:#fff;}
.ad_time span{ font-weight:bold; color:#cc0; padding:0 5px;}
.close{ width:49px; height:20px; background:url(images/close.png) no-repeat; position:absolute; top:0; right:0; cursor:pointer;}
.btn{ width:100px; height:30px; background:#eee; border:1px solid #ddd; font:normal 12px/30px '寰蒋闆呴粦'; text-align:center; margin:20px auto; cursor:pointer;}
</style>
<script type="text/javascript" src="jquery-1.6.2.min.js" language="javascript"></script>
<script type="text/javascript" language="javascript">
function lxfEndtime(){
 $t=$('#t').html();
 if($t!=0){
  $('#t').html($t-1);
  $i=setTimeout("lxfEndtime()",1000);
 }else{  
  $('.box').hide();
  $('.btn').show();
  $('#t').html(6);
  $('.ad_time').css({'width':'554px','height':'351px'});
  clearTimeout($i);
 }
};
$(document).ready(function(){
 $('.btn').live('click',function(){
  $('.box').show();
  $(this).hide(); 
  $('.ad_time').animate({width:110,height:18},'slow');
  lxfEndtime();
 })
 $('.close').click(function(){
  $('.box').hide();
  $('.btn').show();
  $('#t').html(6);
  $('.ad_time').css({'width':'554px','height':'351px'});
  clearTimeout($i);
 })
});
</script>
</head>
<body>
<!--代码开始-->
<div class="box">
 <div class="ad"><a href="#" target="_blank"><img src="images/ad.jpg" /></a></div>
 <div class="ad_time">时间还剩<span id="t">50</span>秒</div>
 <div class="close"></div>
</div>
<div class="btn">点击显示效果</div>
<!--代码结束-->
</body>
</html>

この記事が皆さんの jquery プログラミング設計に役立つことを願っています。

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。