當前位置:首頁 » 網購平台 » jq插件浮動購物車交互效果
擴展閱讀
寧波奧德賽優惠價格 2021-03-15 14:26:02
丹尼斯購物卡能掛失么 2021-03-15 14:25:58
淘寶購物指紋驗證失敗 2021-03-15 14:24:44

jq插件浮動購物車交互效果

發布時間: 2021-02-26 14:45:15

❶ 用JQ實現購物車連接資料庫的功能,怎樣取到資料庫在頁面顯示的單價值,謝謝

你就放在label中就好了.比如頁面是<label id="price">9</label>,jquery的寫法是var price = $("#price").text();

❷ jquery實現購物車物品加減 沒效果,求解

你選擇器來取錯了,沒取到兩個按鈕:自
注意看,#是 id選擇器,class選擇器是以「.」開頭的。
你的代碼裡面 加減兩個按鈕的 id分別為:add1 和 min1 而它們的class為: add和min
所以正確的做法是
$("#add") ---> $("#add1") 、 $("#min") ---> $("#min1")
或者
$("#add") ---> $(".add") 、 $("#min") ---> $(".min")
有不明白的歡迎追問^_^

❸ jquery實現添加到購物車拖放功能 像百度旅遊定製旅遊一樣 如下圖

這功能網路內部有專門開發的。
拖拉帶拽的功能你可以看下jquery ui,裡面有部分功能可以拖動和獲取的,這功能要實現,代碼會有點復雜。
你先自己搜搜看吧

❹ jquery 實現加入購物車功能

參考以下代碼:

注意需要導入.js.

<!DOCTYPEhtml>
<html>
<head>
<title>購物車----jQuery</title>
<metacharset="utf-8"/>
<styletype="text/css">
h1{
text-align:center;
}
table{
margin:0auto;
width:60%;
border:2pxsolid#aaa;
border-collapse:collapse;
}
tableth,tabletd{
border:2pxsolid#aaa;
padding:5px;
}
th{
background-color:#eee;
}
</style>
<scripttype="text/javascript"src="./js/jquery.js"></script>
<scripttype="text/javascript">
functionadd_shoppingcart(btn){//將btn(dom)轉換為jQuery對象
//先獲取商品名字和單價還有庫存以備後面使用
var$tds=$(btn).parent().siblings();
//$tds.eq(0)是jQuery對象$tds[0]是DOM對象
varname=$tds.eq(0).html();//string
varprice=$tds.eq(1).html();//string
varstock=$tds.eq(3).html();//string

//查看庫存是否還有<=0
if(stock<=0){
return;
}

//無論購物車中是否有該商品,庫存都要-1
$tds.eq(3).html(--stock);

//在添加之前確定該商品在購物車中是否存在,若存在,則數量+1,若不存在則創建行
var$trs=$("#goods>tr");
for(vari=0;i<$trs.length;i++){
var$gtds=$trs.eq(i).children();
vargName=$gtds.eq(0).html();
if(name==gName){//若存在
varnum=parseInt($gtds.eq(2).children().eq(1).val());
$gtds.eq(2).children().eq(1).val(++num);//數量+1
//金額從新計算
$gtds.eq(3).html(price*num);
return;//後面代碼不再執行
}
}
//若不存在,創建後追加
varli=
"<tr>"+
"<td>"+name+"</td>"+
"<td>"+price+"</td>"+
"<tdalign='center'>"+
"<inputtype='button'value='-'onclick='decrease(this);'/>"+
"<inputtype='text'size='3'readonlyvalue='1'/>"+
"<inputtype='button'value='+'onclick='increase(this);'/>"+
"</td>"+
"<td>"+price+"</td>"+
"<tdalign='center'>"+
"<inputtype='button'value='x'onclick='del(this);'/>"+
"</td>"+
"</tr>";
//追加到#goods後面
$("#goods").append($(li));

//總計功能
total();
}

//輔助方法--單擊購物車中的"+""-""x"按鈕是找到相關商品所在td,以jQuery對象返回
functionfindStock(btn){
varname=$(btn).parent().siblings().eq(0).html();//獲取商品名字
//注意table默認有行分組,若此處使用$("#table1>tr:gt(0)")則找不到任何tr
var$trs=$("#table1>tbody>tr:gt(0)");
for(vari=0;i<$trs.length;i++){
varfName=$trs.eq(i).children().eq(0).html();
if(name==fName){//找到匹配的商品
return$trs.eq(i).children().eq(3);
}
}
}

//增加"+"功能
functionincrease(btn){
//獲取該商品庫存看是否<=0
var$stock=findStock(btn);
varstock=$stock.html();
if(stock<=0){
return;
}
//庫存-1
$stock.html(--stock);
//購物車數據改變
var$td=$(btn).prev();
varnum=parseInt($td.val());//number
//num此時為number類型(在計算時會自動轉換為number類型)
$td.val(++num);
//獲取單價,再加計算前要先轉換為number類型
varprice=parseInt($(btn).parent().prev().html());
$(btn).parent().next().html(num*price);

//總計功能
total();
}

//減少"-"功能
functiondecrease(btn){
//該商品數量=1時候不能再減少
varnum=parseInt($(btn).next().val());
if(num<=1){
return;
}
var$stock=findStock(btn);
//庫存+1
varstock=$stock.html();
$stock.html(++stock);
//商品數量-1
$(btn).next().val(--num);
//從新計算金額
varprice=parseInt($(btn).parent().prev().html());
$(btn).parent().next().html(price*num);

//總計功能
total();
}

//"x"刪除按鈕功能
functiondel(btn){
//將商品數量歸還庫存
var$stock=findStock(btn);
varstock=parseInt($stock.html());
varnum=parseInt($(btn).parent().prev().prev().children().eq(1).val());
$stock.html(num+stock);
//清空改行商品列表
$(btn).parent().parent().remove();

//總計功能
total();
}
//總計功能
functiontotal(){
//獲取所有購物車中的trs
var$trs=$("#goodstr");
varamount=0;
for(vari=0;i<$trs.length;i++){
varmoney=parseInt($trs.eq(i).children().eq(3).html());
amount+=money;
}
//寫入總計欄
$("#total").html(amount);
}
</script>
</head>
<body>
<h1>真劃算</h1>
<tableid="table1">
<tr>
<th>商品</th>
<th>單價(元)</th>
<th>顏色</th>
<th>庫存</th>
<th>好評率</th>
<th>操作</th>
</tr>
<tr>
<td>羅技M185滑鼠</td>
<td>80</td>
<td>黑色</td>
<td>5</td>
<td>98%</td>
<tdalign="center">
<inputtype="button"value="加入購物車"onclick="add_shoppingcart(this);"/>
</td>
</tr>
<tr>
<td>微軟X470鍵盤</td>
<td>150</td>
<td>黑色</td>
<td>9028</td>
<td>96%</td>
<tdalign="center">
<inputtype="button"value="加入購物車"onclick="add_shoppingcart(this);"/>
</td>
</tr>
<tr>
<td>洛克iphone6手機殼</td>
<td>60</td>
<td>透明</td>
<td>672</td>
<td>99%</td>
<tdalign="center">
<inputtype="button"value="加入購物車"onclick="add_shoppingcart(this);"/>
</td>
</tr>
<tr>
<td>藍牙耳機</td>
<td>100</td>
<td>藍色</td>
<td>8937</td>
<td>95%</td>
<tdalign="center">
<inputtype="button"value="加入購物車"onclick="add_shoppingcart(this);"/>
</td>
</tr>
<tr>
<td>金士頓U盤</td>
<td>70</td>
<td>紅色</td>
<td>482</td>
<td>100%</td>
<tdalign="center">
<inputtype="button"value="加入購物車"onclick="add_shoppingcart(this);"/>
</td>
</tr>
</table>

<h1>購物車</h1>
<table>
<thead>
<tr>
<th>商品</th>
<th>單價(元)</th>
<th>數量</th>
<th>金額(元)</th>
<th>刪除</th>
</tr>
</thead>
<tbodyid="goods">
</tbody>
<tfoot>
<tr>
<tdcolspan="3"align="right">總計</td>
<tdid="total"></td>
<td></td>
</tr>
</tfoot>
</table>
</body>
</html>

最終效果圖:

❺ javascript淘寶首頁購物車的浮動框是怎麼實現的

就是一個div啊。
使用js和css一起實現的,這樣的代碼頁好找吧。
你去一些素材站,特效網站找找看看。

❻ jquery 彈出框,如下圖 ,加入購物車效果

<!DOCTYPEhtml>

<htmllang="en"xmlns="http://www.w3.org/1999/xhtml">
<head>
<metacharset="utf-8"/>
<title></title>
<scripttype="text/javascript"src="jquery.min.js"></script>
<styletype="text/css">
.des{
width:400px;
margin:0auto;
}

.add2carttip{
width:220px;
height:90px;
padding:0;
border:1pxsolidrgba(69,66,66,0.91);
background-color:#393939;
margin:0auto;
border-radius:12px12px;
position:fixed;
display:none;
}

.add2carttip>div{
vertical-align:middle;
color:#D0D0D0;
text-align:center;
font-size:1.2em;
font-weight:bold;
margin:0;
}

.c-title{
height:39px;
line-height:39px;
border-bottom:1px#D0D0D0solid;
}

.c-content{
height:49px;
line-height:49px;
border-top:1px#D0D0D0solid;
}

.c-add,.c-sub{
display:inline-block;
vertical-align:middle;
width:20px;
font-size:1.5em;
font-weight:bold;
cursor:pointer;
}

.c-sub{
vertical-align:-5px;
font-size:1.8em;
}

.c-count{
width:30px;
height:30px;
border-radius:15px;
border:none;
text-align:center;
font-size:inherit;
}

.c-action{
display:inline-block;
cursor:pointer;
}

.c-add:hover,.c-sub:hover,.c-action:hover{
color:#FAFAFA;
}
</style>
<scripttype="text/javascript">
$(function(){
var$tip=$('.add2carttip');
var$add=$('.c-add');
var$sub=$('.c-sub');
var$count=$('.c-count');
var$action=$('.c-action');

var$win=$(window);

functionsetTipPosition(){
$tip.animate({
left:(($win.width()-$tip.width())/2)+'px',
top:($win.height()*1/3)+'px'
},500);
}
setTipPosition();
$win.on('resize',setTipPosition);

$tip.on('selectstart',function(e){e.preventDefault();returnfalse;});

$add.on('click',function(){
$count.val(parseInt($count.val())+1);
});
$sub.on('click',function(){
$count.val(parseInt(($count.val())-1)||1);
});
$action.on('click',function(){
alert('add'+$count.val()+'tocart.');
});
$('.toggleTip').on('click',function(){
$tip.fadeToggle(500);
});
});
</script>

</head>
<body>
<divclass="des">
不支持IE9以下的IE瀏覽器
<ahref="javascript:void();"class="toggleTip">顯示或隱藏</a>
</div>
<divclass="add2carttip">
<divclass="c-title">
商品詳情
</div>
<divclass="c-content">
<spanclass="c-add">+</span>
<inputtype="text"class="c-count"value="1"/>
<spanclass="c-sub">-</span>
<spanclass="c-action">
加入購物車
</span>
</div>
</div>
</body>
</html>

代碼 。。。

❼ 求助:怎麼樣用jQuery製作出一個圖片飛入購物車的動畫

給你個示例吧,應該能幫助到你

這是html

<inputid="Button1"type="button"value="button"/>
<tablestyle="width:100%;">
<tr>
<td>
<divstyle="width:100px;height:100px;border:1pxsolid#f08080"id="shop">購物車</div>
</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<tdstyle="height:500px">&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>
<divstyle="width:50px;height:50px;background-color:#f08080"id="proct">
商品
</div>
</td>
</tr>
</table>

這個是jQuery代碼:

$(function(){
$("#Button1").click(function(){
varshopOffset=$("#shop").offset();
varcloneDiv=$("#proct").clone();
varproOffset=$("#proct").offset();
cloneDiv.css({"position":"absolute","top":proOffset.top,"left":proOffset.left});
$("#proct").parent().append(cloneDiv);

cloneDiv.animate({
left:shopOffset.left,
top:shopOffset.top
},"slow");
});
});

❽ 基於JavaScript jQuery如何把購物車的商品信息渲染到訂單頁面

OK 幫你搞定。

❾ 如何用jquery上下漂浮的動畫效果

@-webkit-keyframesbounce-down{
25%{
-webkit-transform:translateY(-3px);
}
50%,100%{
-webkit-transform:translateY(0);
}
75%{
-webkit-transform:translateY(3px);
}
}
@keyframesbounce-down{
25%{
transform:translateY(-3px);
}
50%,100%{
transform:translateY(0);
}
75%{
transform:translateY(3px);
}
}
.animate-bounce-down{
-webkit-animation:bounce-down1.3slinearinfinite;
animation:bounce-down1.3slinearinfinite;
}

如果不考慮低版本兼容,css3動畫可以簡單實現,給需要漂浮的元素添加animate-bounce-down這個類就好,浮動效果可以自行調試

❿ jquery曲線飛入購物車效果遇到一點小問題

提供一個思路,僅供參考:

假設你用的是animate,再假設你是通過改變"運動塊"的left值和top值來實現專運動的。
那麼,既然屬是曲線,就會有公式。假如一個拋物線的公式:x2=-2py(x>0)
那麼,你就可以寫一個循環,定義一個變數來表達left和top值,直到到達指定位置,循環結束。示例代碼:

while($top<900){
$left=-sqrt(-2p*$top);
$('.div').animate({left:$left,top:$top},100);
}

這是根據上面假設的拋物線公式確定的。不知道你是否能看懂。