jQuery는 장바구니에 제품 추가 및 결제를 구현합니다.
이번에는 장바구니에 상품 추가 및 결제를 구현하는 jQuery를 가져오겠습니다. jQuery를 사용하여 장바구니에 상품 추가 및 결제를 구현하는 방법은 다음과 같습니다. 살펴보자. <!DOCTYPE html>
<html>
<head>
<metacharset="UTF-8">
<title></title>
<scripttype="text/javascript"src="js/jquery-1.8.3.js"></script>
<script>
/*删除*/
$(function(){
$(".blue").bind("click",function(){
$(this).parent().parent().remove();
totalPrice();
});
/*当鼠标离开文本框时,获取当前值,调用totalPrice()函数进行结算*/
$(".shopping_product_list_5 input").bind("blur",function(){
var t = $(this).val();
totalPrice();
});
var allPrice = 0;
var allReduce = 0;
var allCount = 0;
$("#myTableProduct tr").each(function(){ /*循环购物车列表的每一行*/
var num = parseInt($(this).find(".shopping_product_list_5 input").val()); /*获取文本框中数量值*/
var price = parseFloat($(this).find(".shopping_product_list_4 label").text()); /* 获取商品价格*/
var total = price * num;
allPrice += total; /*计算所有商品的总价格*/
/*获取节省的金额*/
var reduce = parseFloat($(this).find(".shopping_product_list_3 label").text()) - parseFloat($(this).find(".shopping_product_list_4 label").text());
var reducePrice = reduce*num;
allReduce +=reducePrice;
/*获取积分*/
var count = parseFloat($(this).find(".shopping_product_list_2 label").text());
allCount +=count;
});
$("#product_total").text(allPrice.toFixed(2)); /*填写计算结果,其中利用toFixed()函数保留两位小数*/
$("#product_save").text(allReduce.toFixed(2));
$("#product_integral").text(allCount.toFixed(2));
});
function totalPrice(){
var allPrice = 0;
var allReduce = 0;
var allCount = 0;
$("#myTableProduct tr").each(function(){
var num = parseInt($(this).find(".shopping_product_list_5 input").val());
var price = parseFloat($(this).find(".shopping_product_list_4 label").text());
var total = price * num;
allPrice += total;
var reduce = parseFloat($(this).find(".shopping_product_list_3 label").text()) - parseFloat($(this).find(".shopping_product_list_4 label").text());
var reducePrice = reduce*num;
allReduce +=reducePrice;
var count = parseFloat($(this).find(".shopping_product_list_2 label").text());
allCount +=count;
});
$("#product_total").text(allPrice.toFixed(2));
$("#product_save").text(allReduce.toFixed(2));
$("#product_integral").text(allCount.toFixed(2));
}
</script>
</head>
<body>
<pclass="shopping_list_top">您已选购以下商品</p>
<pclass="shopping_list_border">
<tablewidth="100%"border="1px solid #ccc">
<trclass="shopping_list_title">
<tdclass="shopping_list_title_1">商品名</td>
<tdclass="shopping_list_title_2">单品积分</td>
<tdclass="shopping_list_title_3">市场价</td>
<tdclass="shopping_list_title_4">当当价</td>
<tdclass="shopping_list_title_5">数量</td>
<tdclass="shopping_list_title_6">删除</td>
</tr>
</table>
<tablewidth="100%"border="1px solid #ccc"id="myTableProduct">
<trclass="shopping_product_list"id="shoppingProduct_01">
<tdclass="shopping_product_list_1"><ahref="#"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"class="blue">私募(首部披露资本博弈秘密的金融...</a></td>
<tdclass="shopping_product_list_2"><label>189</label></td>
<tdclass="shopping_product_list_3">¥<label>32.00</label></td>
<tdclass="shopping_product_list_4">¥<label>18.90 </label>(59折)</td>
<tdclass="shopping_product_list_5"><inputtype="text"value="1"/></td>
<tdclass="shopping_product_list_6"><ahref="javascript:void(0)"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"class="blue">删除</a></td>
</tr>
<trclass="shopping_product_list"id="shoppingProduct_02">
<tdclass="shopping_product_list_1"><ahref="#"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"class="blue"> 小团圆(张爱玲最神秘小说遗稿)</a></td>
<tdclass="shopping_product_list_2"><label>173</label></td>
<tdclass="shopping_product_list_3">¥<label>28.00</label></td>
<tdclass="shopping_product_list_4">¥<label>17.30</label>(62折)</td>
<tdclass="shopping_product_list_5"><inputtype="text"value="1"/></td>
<tdclass="shopping_product_list_6"><ahref="javascript:void(0)"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"class="blue">删除</a></td>
</tr>
<trclass="shopping_product_list"id="shoppingProduct_03">
<tdclass="shopping_product_list_1"><ahref="#"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"class="blue">不抱怨的世界(畅销全球80国的世界...</a></td>
<tdclass="shopping_product_list_2"><label>154</label></td>
<tdclass="shopping_product_list_3">¥<label>24.80</label></td>
<tdclass="shopping_product_list_4">¥<label>15.40</label> (62折)</td>
<tdclass="shopping_product_list_5"><inputtype="text"value="2"/></td>
<tdclass="shopping_product_list_6"><ahref="javascript:void(0)"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"class="blue">删除</a></td>
</tr>
<trclass="shopping_product_list"id="shoppingProduct_04">
<tdclass="shopping_product_list_1"><ahref="#"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"class="blue">福玛特双桶洗衣机XPB20-07S</a></td>
<tdclass="shopping_product_list_2"><label>358</label></td>
<tdclass="shopping_product_list_3">¥<label>458.00</label></td>
<tdclass="shopping_product_list_4">¥<label>358.00</label> (78折)</td>
<tdclass="shopping_product_list_5"><inputtype="text"value="1"/></td>
<tdclass="shopping_product_list_6"><ahref="javascript:void(0)"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"class="blue">删除</a></td>
</tr>
<trclass="shopping_product_list"id="shoppingProduct_05">
<tdclass="shopping_product_list_1"><ahref="#"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"class="blue">PHP和MySQL Web开发 (原书第4版)</a></td>
<tdclass="shopping_product_list_2"><label>712</label></td>
<tdclass="shopping_product_list_3">¥<label>95.00</label></td>
<tdclass="shopping_product_list_4">¥<label>71.20</label> (75折)</td>
<tdclass="shopping_product_list_5"><inputtype="text"value="1"/></td>
<tdclass="shopping_product_list_6"><ahref="javascript:void(0)"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"class="blue">删除</a></td>
</tr>
<trclass="shopping_product_list"id="shoppingProduct_06">
<tdclass="shopping_product_list_1"><ahref="#"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"class="blue">法布尔昆虫记</a>(再买¥68.30即可参加“满199元减10元现金”活动)</td>
<tdclass="shopping_product_list_2"><label>10</label></td>
<tdclass="shopping_product_list_3">¥<label>198.00</label></td>
<tdclass="shopping_product_list_4">¥<label>130.70</label> (66折)</td>
<tdclass="shopping_product_list_5"><inputtype="text"value="1"/></td>
<tdclass="shopping_product_list_6"><ahref="javascript:void(0)"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"rel="external nofollow"class="blue">删除</a></td>
</tr>
</table>
<pclass="shopping_list_end">
<p><aid="removeAllProduct"href="javascript:void(0);"rel="external nofollow">清空购物车</a></p>
<ul>
<liclass="shopping_list_end_1"><inputname=""type="image"src="images/shopping_balance.gif"/></li>
<liclass="shopping_list_end_2">¥<labelid="product_total"></label></li>
<liclass="shopping_list_end_3">商品金额总计:</li>
<liclass="shopping_list_end_4">您共节省金额:¥<labelclass="shopping_list_end_yellow"id="product_save"></label><br/>
可获商品积分:<labelclass="shopping_list_end_yellow"id="product_integral"></label>
</li>
</ul>
</p>
</p>
</body>
</html>
추천 도서:
jquery 플러그인 확장 사용에 대한 자세한 설명jQuery가 브라우저 버전을 결정하는 방법jQuery 테이블 상단 표시줄 고정 효과위 내용은 jQuery는 장바구니에 제품 추가 및 결제를 구현합니다.의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

드림위버 CS6
시각적 웹 개발 도구

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

뜨거운 주제











jQuery 참조 방법에 대한 자세한 설명: 빠른 시작 가이드 jQuery는 웹 사이트 개발에 널리 사용되는 JavaScript 라이브러리로, JavaScript 프로그래밍을 단순화하고 개발자에게 풍부한 기능을 제공합니다. 이 기사에서는 jQuery의 참조 방법을 자세히 소개하고 독자가 빠르게 시작할 수 있도록 구체적인 코드 예제를 제공합니다. jQuery 소개 먼저 HTML 파일에 jQuery 라이브러리를 도입해야 합니다. CDN 링크를 통해 소개하거나 다운로드할 수 있습니다.

jQuery에서 PUT 요청 방법을 사용하는 방법은 무엇입니까? jQuery에서 PUT 요청을 보내는 방법은 다른 유형의 요청을 보내는 것과 유사하지만 몇 가지 세부 사항과 매개 변수 설정에 주의해야 합니다. PUT 요청은 일반적으로 데이터베이스의 데이터 업데이트 또는 서버의 파일 업데이트와 같은 리소스를 업데이트하는 데 사용됩니다. 다음은 jQuery에서 PUT 요청 메소드를 사용하는 구체적인 코드 예제입니다. 먼저 jQuery 라이브러리 파일을 포함했는지 확인한 다음 $.ajax({u를 통해 PUT 요청을 보낼 수 있습니다.

실용 튜토리얼: PHP 및 MySQL을 사용한 장바구니 기능에 대한 자세한 설명 장바구니 기능은 웹사이트 개발에서 흔히 사용되는 기능 중 하나입니다. 장바구니를 통해 사용자는 구매하려는 상품을 장바구니에 쉽게 추가할 수 있습니다. 그 후 정산 및 결제를 진행합니다. 이 기사에서는 PHP와 MySQL을 사용하여 간단한 장바구니 기능을 구현하는 방법을 자세히 설명하고 구체적인 코드 예제를 제공합니다. 데이터베이스와 데이터 테이블을 생성하려면 먼저 MySQL 데이터베이스에 제품 정보를 저장할 데이터 테이블을 생성해야 합니다. 다음은 간단한 데이터 테이블입니다.

jQuery를 사용하여 요소의 높이 속성을 제거하는 방법은 무엇입니까? 프런트엔드 개발에서는 요소의 높이 속성을 조작해야 하는 경우가 종종 있습니다. 때로는 요소의 높이를 동적으로 변경해야 할 수도 있고 요소의 높이 속성을 제거해야 하는 경우도 있습니다. 이 기사에서는 jQuery를 사용하여 요소의 높이 속성을 제거하는 방법을 소개하고 구체적인 코드 예제를 제공합니다. jQuery를 사용하여 높이 속성을 연산하기 전에 먼저 CSS의 높이 속성을 이해해야 합니다. height 속성은 요소의 높이를 설정하는 데 사용됩니다.

제목: jQuery 팁: 페이지에 있는 모든 태그의 텍스트를 빠르게 수정하세요. 웹 개발에서는 페이지의 요소를 수정하고 조작해야 하는 경우가 많습니다. jQuery를 사용할 때 페이지에 있는 모든 태그의 텍스트 내용을 한 번에 수정해야 하는 경우가 있는데, 이는 시간과 에너지를 절약할 수 있습니다. 다음은 jQuery를 사용하여 페이지의 모든 태그 텍스트를 빠르게 수정하는 방법을 소개하고 구체적인 코드 예제를 제공합니다. 먼저 jQuery 라이브러리 파일을 도입하고 다음 코드가 페이지에 도입되었는지 확인해야 합니다. <

우리가 다양한 선택을 하기 위해 이 플랫폼을 사용할 때, 우리가 구매하는 일부 제품, 특히 우리가 구매하는 신발은 그것이 가짜인지 확실하지 않기 때문에 우리 자신을 더 편안하게 만들기 위해 구매합니다. , 일부 제품에 대해 일부 평가만 수행하여 정품인지 가짜인지 알 수 있습니다. 이는 구매할 때 더 안심할 수 있다는 의미이기도 합니다. 아니, 그래서 오늘은 더 많은 사용자에게 제품 식별 방법을 알리기 위해 편집자가 위의 내용 정보 중 일부를 모든 사람에게 설명할 것이므로 아이디어가 있는 친구는 놓쳐서는 안 됩니다. 편집자와 함께 살펴보세요. 진품을 구별하다

제목: jQuery를 사용하여 모든 태그의 텍스트 내용을 수정합니다. jQuery는 DOM 작업을 처리하는 데 널리 사용되는 인기 있는 JavaScript 라이브러리입니다. 웹 개발을 하다 보면 페이지에 있는 링크 태그(태그)의 텍스트 내용을 수정해야 하는 경우가 종종 있습니다. 이 기사에서는 jQuery를 사용하여 이 목표를 달성하는 방법을 설명하고 구체적인 코드 예제를 제공합니다. 먼저 페이지에 jQuery 라이브러리를 도입해야 합니다. HTML 파일에 다음 코드를 추가합니다.

1. 먼저 [Meituan] 앱 소프트웨어를 열고 [전자상거래] 페이지에서 즐겨찾는 [제품] 옵션을 클릭하여 [제품 세부정보] 페이지로 들어갑니다. 2. 그런 다음 [상품 상세정보] 페이지 하단 기능바에 있는 [장바구니에 담기] 버튼을 클릭하세요. 3. 옵션 목록에서 원하는 [사양] 옵션을 클릭한 후, [확인] 버튼을 클릭하면 장바구니에 성공적으로 추가됩니다.
