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

jQuery實(shí)現(xiàn)簡(jiǎn)易商城系統(tǒng)項(xiàng)目實(shí)操

 更新時(shí)間:2022年06月29日 15:27:23   作者:張阿起  
這篇文章主要介紹了jQuery實(shí)現(xiàn)簡(jiǎn)易商城系統(tǒng)項(xiàng)目實(shí)操,文章圍繞主題展開(kāi)詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值,感興趣的小伙伴可以參考一下

一.效果圖

二.body

<body> 
<table border="1" cellpadding="0" cellspacing="0"> 
	<tr>
    	<th><input type='checkbox' name="c1"/>全選</th>
        <th>商品信息</th>
        <th>宜美惠價(jià)</th>
        <th>數(shù)量</th>
        <th>操作</th>

    </tr>

   	<tr class="tr_0">
       	<td>
           	<input name="" type="checkbox" value=""/>
           </td>
           <td>
           	<img src="images/sang.gif" class="products"/><a href="#" rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  rel="external nofollow" >天堂雨傘</a></td><td>¥32.9元
           </td>
           <td>
         	  	<img src="images/subtraction.gif" width="20" height="20"/>
           	<input type="text" class="quantity" value="1"/>
           	<img src="images/add.gif" width="20" height="20"/>
          </td>
          <td>
          		<a href="#" rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  class="del">刪除</a>
          </td>
       </tr>
       <tr>
       	<td>
           	<input name="" type="checkbox" value=""/>
           </td>
           <td>
           	<img src="images/iphone.gif" class="products"/><a href="#" rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  rel="external nofollow" >蘋(píng)果手機(jī)iphone5</a></td><td>¥3339元
           </td>
           <td>
         	  	<img src="images/subtraction.gif" width="20" height="20"/>
           	<input type="text" class="quantity" value="1"/>
           	<img src="images/add.gif" width="20" height="20"/>
          </td>
          <td>
          		<a href="#" rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  class="del">刪除</a>
          </td>
       </tr>
 </table>
 <a href="#" rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  class="add">添加</a>
</body>

三.jQuery

<script type="text/javascript" src="js/jquery-1.12.4.js" ></script>
<script>
	$(function(){
		//點(diǎn)擊加號(hào)觸發(fā)事件
		$('[src="images/add.gif"]').click(function(){
			var num=parseInt($(this).prev().val());
			$(this).prev().val(num+1);
		});
		//點(diǎn)擊減號(hào)觸發(fā)事件
		$('[src="images/subtraction.gif"]').click(function(){
			var num=parseInt($(this).next().val());
			if(num<=0){
				return alert('不能再少了!');
			};
			$(this).next().val(num-1);
		});
		//刪除事件
		$('[class="del"]').click(function(){
			$(this).parent().parent().remove();
		});
		//選中框,全選框事件
		$('[type="checkbox"]').click(function(){
			var len=$('[type="checkbox"]').length;
			var clen=$('[type="checkbox"]:checked').length;
			var t1=$('[name="c1"]').prop("checked");
			var pd=$(this).parent().text();
			if(pd=="全選"){
				$('[name="c1"]').prop("checked",t1);
				$('[type="checkbox"]').prop("checked",t1);
				return "";
			}
			if(clen==len-1 & t1==false){
				$('[name="c1"]').prop("checked",true);
			}else if(clen>=len-1 & t1==true){
				$('[name="c1"]').prop("checked",false);
			}
		});
		//添加事件
		$('[class="add"]').click(function(){
			var newD=$('tr:eq(2)').clone();
			$('tr:last').after(newD);
		});
		
		//輸入框
		$('[type="text"]').change(function(){
			var te=$(this).val();
			te=te.toString();
			for(i=0;i<te.length;i++){
				if(i==2 || te[i]=="."){
					alert('不能超過(guò)100,不能有小數(shù)');
					return $(this).val(1);
				};
			};
			if(te<=0 || isNaN(te)){
				$(this).val(1);
			};
			
		});
	});
</script>

四.css

<style type="text/css" >
*{
	font-size:12px;
}
</style>

五.小結(jié)

本章使用jQuery的方式實(shí)現(xiàn)了一個(gè)簡(jiǎn)易的商城系統(tǒng),這一個(gè)比較潦草,明天再實(shí)現(xiàn)一個(gè)比較好看的.

到此這篇關(guān)于jQuery實(shí)現(xiàn)簡(jiǎn)易商城系統(tǒng)項(xiàng)目實(shí)操的文章就介紹到這了,更多相關(guān)jQuery商城系統(tǒng)內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論

噶尔县| 探索| 元氏县| 开阳县| 镶黄旗| 华池县| 福建省| 民权县| 西充县| 西充县| 长泰县| 横山县| 石家庄市| 郑州市| 雷山县| 郴州市| 凉城县| 扶绥县| 宁波市| 孝义市| 南京市| 南澳县| 河池市| 九台市| 凤台县| 银川市| 吉林省| 基隆市| 滨海县| 阿尔山市| 蚌埠市| 胶州市| 襄城县| 伊春市| 山西省| 鄄城县| 昌平区| 霍林郭勒市| 潞城市| 台北市| 开封县|