欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jQuery實(shí)現(xiàn)的選擇商品飛入文本框動(dòng)畫效果完整實(shí)例

 更新時(shí)間:2016年08月10日 09:42:02   作者:Quber  
這篇文章主要介紹了jQuery實(shí)現(xiàn)的選擇商品飛入文本框動(dòng)畫效果,結(jié)合完整實(shí)例形式分析了jQuery動(dòng)態(tài)操作頁面元素屬性實(shí)現(xiàn)動(dòng)畫效果的方法,涉及jQuery的事件綁定、元素遍歷及屬性操作等相關(guān)技巧,需要的朋友可以參考下

本文實(shí)例講述了jQuery實(shí)現(xiàn)的選擇商品飛入文本框動(dòng)畫效果。分享給大家供大家參考,具體如下:

<!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>
  <title></title>
  <script src="jquery-1.7.2.min.js" type="text/javascript"></script>
  <script>
    $(function() {
      initProListClick();
    });
    function initProListClick() {
      var brandUlObj = $('#brandListForOperate li');
      brandUlObj.unbind('click').on('click', function () {
        var thisLiObj = $(this);
        //獲取商品的值和名稱
        var thisProValue = thisLiObj.find('input').val(),
          thisProName = thisLiObj.find('.brand-text').text();
        //調(diào)用動(dòng)畫效果方法
        moveProEffect(thisLiObj, thisProValue, thisProName);
        brandUlObj.find('input').attr({ 'checked': false });
        brandUlObj.not(thisLiObj).removeClass('brand-selected');
        if (thisLiObj.hasClass('brand-selected')) {
          thisLiObj.find('input').attr({ 'checked': true });
          // thisLiObj.removeClass('brand-selected');
          // thisLiObj.find('input').attr({'checked':false});
        } else {
          thisLiObj.addClass('brand-selected');
          thisLiObj.find('input').attr({ 'checked': true });
        }
      });
    }
    //定義選擇商品一共飛入的效果
    function moveProEffect(obj, brandVal, brandName) {
      //獲取每一個(gè)LI標(biāo)簽的left top距離
      var divTop = $(obj).offset().top;
      var divLeft = $(obj).offset().left;
      //定義移動(dòng)效果的div,并將點(diǎn)擊的LI中的html內(nèi)容放入此div中
      var thisEffectObj = $('#proEffectPanel');
      thisEffectObj.html(obj.html()).find('input').attr({ "checked": true });
      //初始化定義移動(dòng)效果的div樣式
      $(thisEffectObj).css({ "position": "static", "display": "none", "z-index": "auto", "left": "auto", "top": "auto", "opacity": "1", "border-radius": "0px" });
      //移動(dòng)過程中div的樣式
      $(thisEffectObj).css({ "position": "absolute", "display": "block", "z-index": "500", "left": divLeft + "px", "top": divTop + "px", "border-radius": "4px" });
      $(thisEffectObj).animate({
        "left": ($("#txtProName").offset().left - $("#txtProName").width()+165) + "px",
        "top": ($(document).scrollTop()) + "px",
        "width": "190px",
        "height": "30px"
      }, 500, function () {
        $(thisEffectObj).animate({
          "left": ($("#txtProName").offset().left -7) + "px",
          "top": ($("#txtProName").offset().top-5) + "px"
        }, 500, function () {
          $('#txtProName').val(brandName);
        }).fadeTo(0, 0.1).hide(0);
      });
    }
  </script>
</head>
<body>
  <style>
    html,body{font-size: 12px;color: #696969;font-family: 'Microsoft YaHei';}
    .txt-main { height: 30px; line-height: 30px; border: 1px solid #c3c3c3; border-radius: 4px; padding: 0 4px; width: 180px; background: #fff url(image/form/form-input-txt-bg.png) repeat-x; }
    .txt-main:focus { color: #2a6894; border-color: #66afe9; outline: 0; -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(102, 175, 233, 0.6); box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(102, 175, 233, 0.6); }
    .pro-list-panel{ width: 330px;overflow: hidden;border: 1px solid #f3f3f3;padding-bottom: 10px;float: left;margin-left: 10px;}
    .pro-list-main{list-style-type: none;overflow: hidden;padding: 0;margin: 0;}
    .pro-list-main li, #proEffectPanel { border: 1px solid #95b8e7; width: 147px; overflow: hidden; float: left; margin-left: 5px; margin-top: 5px; height: 30px; line-height: 30px; }
    .pro-list-main li div, #proEffectPanel div { float: left; height: 30px; line-height: 30px; }
    .pro-list-main li div.brand-chk, #proEffectPanel div.brand-chk { width: 12px; padding: 5px 6px 0 5px; }
    .pro-list-main li div.brand-text, #proEffectPanel div.brand-text { width: 124px; }
    .pro-list-main li:hover, .pro-list-main li.brand-selected, #proEffectPanel { background-color: #ceebf4; }
  </style>
  <div class="pro-list-panel">
    <h2> 選擇你的商品:</h2>
    <ul class="pro-list-main" id="brandListForOperate">
      <li title="康師傅">
        <div class="brand-chk"><input type="checkbox" id="Checkbox1" value="1" /></div>
        <div class="brand-text">康師傅</div>
      </li>
      <li title="鴻星爾克">
        <div class="brand-chk"><input type="checkbox" id="Checkbox2" value="2" /></div>
        <div class="brand-text">鴻星爾克</div>
      </li>
      <li title="程輝">
        <div class="brand-chk"><input type="checkbox" id="Checkbox3" value="2" /></div>
        <div class="brand-text">程輝</div>
      </li>
      <li title="士力架">
        <div class="brand-chk"><input type="checkbox" id="Checkbox4" value="2" /></div>
        <div class="brand-text">士力架</div>
      </li>
      <li title="三笑">
        <div class="brand-chk"><input type="checkbox" id="Checkbox5" value="2" /></div>
        <div class="brand-text">三笑</div>
      </li>
      <li title="椰牛">
        <div class="brand-chk"><input type="checkbox" id="Checkbox6" value="2" /></div>
        <div class="brand-text">椰牛</div>
      </li>
      <li title="飛科">
        <div class="brand-chk"><input type="checkbox" id="Checkbox7" value="2" /></div>
        <div class="brand-text">飛科</div>
      </li>
    </ul>
    <div id="proEffectPanel" style="display: none;">
    </div>
  </div>
  <div class="pro-list-panel">
    <h2> 你選擇的商品·:</h2>
      <input type="text" name="txtProName" value="" id="txtProName" class="txt-main" />
  </div>
</body>
</html>

運(yùn)行效果截圖如下:

更多關(guān)于jQuery相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《jQuery常用插件及用法總結(jié)》、《jQuery常見經(jīng)典特效匯總》、《jQuery form操作技巧匯總》、《jQuery操作json數(shù)據(jù)技巧匯總》、《jQuery擴(kuò)展技巧總結(jié)》、《jQuery拖拽特效與技巧總結(jié)》、《jQuery表格(table)操作技巧匯總》、《jquery中Ajax用法總結(jié)》、《jQuery動(dòng)畫與特效用法總結(jié)》及《jquery選擇器用法總結(jié)

希望本文所述對(duì)大家jQuery程序設(shè)計(jì)有所幫助。

相關(guān)文章

  • JQuery獲取當(dāng)前屏幕的高度寬度的實(shí)現(xiàn)代碼

    JQuery獲取當(dāng)前屏幕的高度寬度的實(shí)現(xiàn)代碼

    JQuery獲取瀏覽器窗口寬高,文檔寬高的代碼,使用jquery的朋友可以參考下。
    2011-07-07
  • 使用jQueryMobile實(shí)現(xiàn)滑動(dòng)翻頁效果的方法

    使用jQueryMobile實(shí)現(xiàn)滑動(dòng)翻頁效果的方法

    這篇文章主要介紹了使用jQueryMobile實(shí)現(xiàn)滑動(dòng)翻頁效果的方法,較為詳細(xì)的分析了jQueryMobile實(shí)現(xiàn)滑動(dòng)翻頁效果的原理與實(shí)現(xiàn)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
    2015-02-02
  • 解決jQuery uploadify在非IE核心瀏覽器下無法上傳

    解決jQuery uploadify在非IE核心瀏覽器下無法上傳

    之前上傳了一個(gè)通過Flash實(shí)現(xiàn)多文件上傳,但是在IE正常運(yùn)行,F(xiàn)ireFox 不能正常上傳。經(jīng)過反復(fù)研究學(xué)習(xí),之所以firefox和360瀏覽器無法正常運(yùn)行,是因?yàn)镕ireFox、chrome、360瀏覽器等支持HTML5的瀏覽器不會(huì)再文件上傳時(shí)自動(dòng)帶入session信息和cookie,不共享session。
    2015-08-08
  • jQuery.getScript加載同域JS的代碼

    jQuery.getScript加載同域JS的代碼

    jQuery.getScript加載同域JS為xhr請求,導(dǎo)致firebug不能正常讀取js,因此不能夠斷點(diǎn)該js
    2012-02-02
  • jQuery獲取同級(jí)元素的簡單代碼

    jQuery獲取同級(jí)元素的簡單代碼

    下面小編就為大家?guī)硪黄猨Query獲取同級(jí)元素的簡單代碼。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2016-07-07
  • jQuery File Upload文件上傳插件使用詳解

    jQuery File Upload文件上傳插件使用詳解

    jQuery File Upload 是一個(gè)Jquery文件上傳組件,支持多文件上傳、取消、刪除,上傳前縮略圖預(yù)覽、列表顯示圖片大小,支持上傳進(jìn)度條顯示;支持各種動(dòng)態(tài)語言開發(fā)的服務(wù)器端.這篇文章主要介紹了jQuery File Upload文件上傳插件使用,需要的朋友可以參考下
    2016-12-12
  • jQuery操作Dom元素與遍歷以及JS遍歷詳細(xì)講解

    jQuery操作Dom元素與遍歷以及JS遍歷詳細(xì)講解

    這篇文章主要介紹了jQuery操作Dom元素、jQuery遍歷、JavaScript遍歷,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧
    2023-01-01
  • jquery 表格排序、實(shí)時(shí)搜索表格內(nèi)容(附圖)

    jquery 表格排序、實(shí)時(shí)搜索表格內(nèi)容(附圖)

    這篇文章主要介紹了jquery如何實(shí)現(xiàn)表格排序、實(shí)時(shí)搜索表格內(nèi)容,需要的朋友可以參考下
    2014-05-05
  • jQuery防止重復(fù)綁定事件的解決方法

    jQuery防止重復(fù)綁定事件的解決方法

    這篇文章主要介紹了jQuery防止重復(fù)綁定事件的解決方法,結(jié)合實(shí)例形式分析了jQuery的重復(fù)綁定問題與相應(yīng)的解決方法,需要的朋友可以參考下
    2016-05-05
  • 簡單介紹jsonp 使用小結(jié)

    簡單介紹jsonp 使用小結(jié)

    Jsonp(JSON with Padding) 是 json 的一種"使用模式",可以讓網(wǎng)頁從別的域名(網(wǎng)站)那獲取資料,即跨域讀取數(shù)據(jù),本文給大家簡單介紹jsonp 使用小結(jié) ,需要的朋友參考下
    2016-01-01

最新評(píng)論