成人精品一区二区三区中文字幕-成人精品一区二区三区-成人精品一级毛片-成人精品亚洲-日本在线视频一区二区-日本在线视频免费

導(dǎo)航首頁(yè) ? 技術(shù)教程 ? jQuery實(shí)現(xiàn)的選擇商品飛入文本框動(dòng)畫(huà)效果完整實(shí)例
全站頭部文字 我要出現(xiàn)在這里
jQuery實(shí)現(xiàn)的選擇商品飛入文本框動(dòng)畫(huà)效果完整實(shí)例 651 2024-02-22   

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

<!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="http://www.gimoo.net/t/1901/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)畫(huà)效果方法
        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)過(guò)程中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常見(jiàn)經(jīng)典特效匯總》、《jQuery form操作技巧匯總》、《jQuery操作json數(shù)據(jù)技巧匯總》、《jQuery擴(kuò)展技巧總結(jié)》、《jQuery拖拽特效與技巧總結(jié)》、《jQuery表格(table)操作技巧匯總》、《jquery中Ajax用法總結(jié)》、《jQuery動(dòng)畫(huà)與特效用法總結(jié)》及《jquery選擇器用法總結(jié)》

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



主站蜘蛛池模板: 红星闪闪简谱| 暗恋桃花源剧本| 杯弓蛇影读后感| 圆的认识评课| 手绢舞蹈视频大全| 难忘的运动会作文| 上门女婿电影完整版免费| 女同性恋中文字幕| 母亲电影韩国完整版免费观看| 今天是你的生日bb伴奏正谱| 速度与激情10什么时候上映的| 浣肠アナル地狱| 女神异闻录5动画| 爱情岛论坛.| 西海情歌歌词全文| 美女网站免费观看视频| 奇骏车友会| 妻子的电视剧| 今天是你的生日bb伴奏正谱| 鬼龙院花子的一生| 信我者无需多言,不信我者| 年会不能停豆瓣评分| 小镇姑娘高清播放| 杀破狼·贪狼 2017 古天乐| 补充电解质喝什么饮料| 爱自有天意| 苏教版二年级下册数学| 老司机免费在线视频| 爱丽丝梦游仙境电影| 汪始慧| 喝醉的图片| 周岁封酒| 福田麻由子| 二年级53天天练语文上册答案 | 哈尔的移动城堡免费完整版| 罗比威廉姆斯| 富含维生素c的水果和蔬菜| 甲铁城的卡巴内利| 石灰吟教学设计一等奖优质课| 远景山谷1981免费版| 迷失美剧|

!!!站長(zhǎng)長(zhǎng)期在線接!!!

網(wǎng)站、小程序:定制開(kāi)發(fā)/二次開(kāi)發(fā)/仿制開(kāi)發(fā)等

各種疑難雜癥解決/定制接口/定制采集等

站長(zhǎng)微信:lxwl520520

站長(zhǎng)QQ:1737366103