最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

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

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

<!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)用動畫效果方法
        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) {
      //獲取每一個LI標簽的left top距離
      var divTop = $(obj).offset().top;
      var divLeft = $(obj).offset().left;
      //定義移動效果的div,并將點擊的LI中的html內(nèi)容放入此div中
      var thisEffectObj = $('#proEffectPanel');
      thisEffectObj.html(obj.html()).find('input').attr({ "checked": true });
      //初始化定義移動效果的div樣式
      $(thisEffectObj).css({ "position": "static", "display": "none", "z-index": "auto", "left": "auto", "top": "auto", "opacity": "1", "border-radius": "0px" });
      //移動過程中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>

運行效果截圖如下:

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

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

相關(guān)文章

最新評論

闽清县| 灵璧县| 沅陵县| 敦煌市| 沁源县| 广灵县| 稷山县| 诸暨市| 新余市| 瑞昌市| 秦皇岛市| 彭州市| 水富县| 黄山市| 定远县| 肇州县| 湘阴县| 石楼县| 宝兴县| 报价| 呼图壁县| 扎鲁特旗| 北宁市| 襄汾县| 芜湖县| 淳化县| 介休市| 海宁市| 融水| 揭东县| 县级市| 翼城县| 尚志市| 海丰县| 永定县| 拜城县| 界首市| 晋宁县| 博湖县| 长乐市| 淳安县|