zoukankan      html  css  js  c++  java
  • 写了一个小焦点图组件 就一个左右按钮 一共就几行代码 好用 sfocus

    调用语句:sfocusBind("#sfocus","#btnLeft","#btnRight");

    简简单单 就是最简单的功能

    下载地址 https://files.cnblogs.com/pengpengsay/jqueryStudy.rar

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    <script type="text/javascript" src="jquery.js"></script>
    <script>
    $(document).ready(function(){
      $("#jQueryShowBtn").click(function(){$("#jQueryShowTxt").show();});
      $("#jQueryHideBtn").click(function(){$("#jQueryShowTxt").hide();});
      $("#jQueryToggleBtn").click(function(){$("#jQueryShowTxt").toggle();});
      $("#jQueryShowBtn2").click(function(){$("#jQueryShowTxt2").show("slow");});
      $("#jQueryHideBtn2").click(function(){$("#jQueryShowTxt2").hide("slow");});
      $("#jQueryToggleBtn2").click(function(){$("#jQueryShowTxt2").toggle("fast")});
      
     
    
    });
    </script>
    </head>
    
    <body>
    
    
    <div>
    <h3>show(speed, [callback])</h3>
    <a id="jQueryShowBtn2">显示</a> <a id="jQueryHideBtn2">隐藏</a> <a id="jQueryToggleBtn2">转换</a> 
    <a onclick="javascript:$('#jQueryShowTxt2').slideDown('fast');">slideDown</a>
    <a onclick="javascript:$('#jQueryShowTxt2').slideUp('fast');">slideUp</a>
    <a onclick="javascript:$('#jQueryShowTxt2').slideToggle('fast');">slideToggle</a>
    <a onclick="javascript:$('#jQueryShowTxt2').fadeIn('fast');">fadeIn</a>
    <a onclick="javascript:$('#jQueryShowTxt2').fadeOut('fast');">fadeOut</a>
    <a onclick="javascript:$('#jQueryShowTxt2').fadeTo('fast',0.25);">fadeTo</a>
    <a onclick="javascript:$('#jQueryShowTxt2').animate({'toggle'},'fast');">animate</a>
    
    
    
    
    <div id="jQueryShowTxt2" style="display:none; background-color:#f2f2f2;">show(speed, [callback])<br />三种预定速度之一的字符串("slow", "normal", or "fast")或表示动画时长的毫秒数值(如:1000)
    
    </div>
    </div>
    
    
    
    <div>
    <h3>jQuery.show()/jQuery.hide()/jQuery.toggle()</h3>
    <a id="jQueryShowBtn">显示</a> <a id="jQueryHideBtn">隐藏</a> <a id="jQueryToggleBtn">转换</a> <div id="jQueryShowTxt" style="display:none; background-color:#f2f2f2;">jQuery.show()</div>
    </div><br />
    <br />
    <br />
    
    <script>
    $(document).ready(function(){
    	function sfocusBind(focusId,btnLeftId,btnRightId){
    		$(focusId+" ul").width($(focusId+" ul li").width()*($(focusId+" ul li").length));
    		var sfocusCurr = 0;
    		$(btnRightId).click(function(){
    			
    			if(sfocusCurr < $(focusId+" ul li").length-1)
    			{
    				sfocusCurr++;
    				$(focusId+" ul").animate({left:-sfocusCurr*$(focusId+" ul li").width()},"fast");
    				}
    			});
    		$(btnLeftId).click(function(){
    			if(sfocusCurr > 0)
    			{
    				sfocusCurr--;
    				$(focusId+" ul").animate({left:-sfocusCurr*$(focusId+" ul li").width()},"fast");
    				}
    			});
    	}
    	sfocusBind("#sfocus","#btnLeft","#btnRight");
    	sfocusBind("#sfocus2","#btnLeft2","#btnRight2");
    });
    </script>
    <style>
    .sfocusClass {overflow:hidden; position:absolute;}
    .sfocusClass ul{margin:0; padding:0; border:0; position:relative;}
    .sfocusClass ul li{list-style-type:none; float:left;}
    .btnLeftClass {}
    .bntRightClass {}
    </style>
    
    <table width="192" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="250">
        <div><a id="btnLeft" style="cursor:pointer;">向左</a> <a id="btnRight" style="cursor:pointer;">向右</a></div>
    <div id="sfocus" class="sfocusClass" style="192px; height:192px;overflow:hidden;">
    <ul>
    <li><img src="1.jpg" /></li>
    <li><img src="2.jpg" /></li>
    <li><img src="3.jpg" /></li>
    <li><img src="1.jpg" /></li>
    <li><img src="2.jpg" /></li>
    <li><img src="3.jpg" /></li>
    </ul>
    </div>
        </td>
      </tr>
    </table>
    <table width="192" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="250"><div><a id="btnLeft2" style="cursor:pointer;">向左</a> <a id="btnRight2" style="cursor:pointer;">向右</a></div>
          <div id="sfocus2" class="sfocusClass" style="192px; height:192px;overflow:hidden;">
            <ul>
              <li><img src="1.jpg" /></li>
              <li><img src="2.jpg" /></li>
              <li><img src="3.jpg" /></li>
              <li><img src="1.jpg" /></li>
              <li><img src="2.jpg" /></li>
              <li><img src="3.jpg" /></li>
            </ul>
          </div></td>
      </tr>
    </table>
    </body>
    </html>
    
    ---------------------------------------------
    生活的意义并不是与他人争高下,而在于享受努力实现目标的过程,结果是对自己行动的嘉奖。
    ↑面的话,越看越不痛快,应该这么说:

    生活的意义就是你自己知道你要做什么,明确目标。没有目标,后面都是瞎扯!
  • 相关阅读:
    C++ 模板特化
    左值引用,右值引用以及移动语义
    搜狐2016研发工程师编程题
    java配置环境变量与常用技巧
    java在线聊天项目 使用SWT快速制作登录窗口,可视化窗口Design 更换窗口默认皮肤(切换Swing自带的几种皮肤如矩形带圆角)
    c++中的结构体:声明 定义 初始化
    用指针变量作函数形参接收数组地址,解决10个整数按由小到大顺序排序问题
    java在线聊天项目 实现基本聊天功能后补充的其他功能详细需求分析 及所需要掌握的Java知识基础 SWT的激活方法,swt开发包下载,及破解激活码
    java在线聊天项目1.0版 异常处理——开启多个客户端,关闭一个客户端后,在其他客户端中再发出信息会出现异常的处理
    第十一次作业
  • 原文地址:https://www.cnblogs.com/pengchenggang/p/2451837.html
Copyright © 2011-2022 走看看