jquery+json實(shí)現(xiàn)動(dòng)態(tài)商品內(nèi)容展示的方法
本文實(shí)例講述了jquery+json實(shí)現(xiàn)動(dòng)態(tài)商品內(nèi)容展示的方法。分享給大家供大家參考,具體如下:
<!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" xml:lang="zh" lang="zh" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<mce:script type="text/javascript" src="jquery-1.4.4.min.js" mce_src="jquery-1.4.4.min.js"></mce:script>
<title>Example | xHTML1.0</title>
</head>
<mce:style><!--
div{width:50px;height:50px;float:left;margin:10px; text-align:center;}
.a{font-size:50px;float:left; cursor:pointer;}
.b{font-size:50px;background-color:yellow;float:left; cursor:pointer;}
.border{border:2px solid;}
.bb{}
--></mce:style><style mce_bogus="1">div{width:50px;height:50px;float:left;margin:10px; text-align:center;}
.a{font-size:50px;float:left; cursor:pointer;}
.b{font-size:50px;background-color:yellow;float:left; cursor:pointer;}
.border{border:2px solid;}
.bb{}</style>
<mce:script type="text/javascript"><!--
$(function () {
var _json = {"red":{"small":"10","middle":"15","large":"20","max_large":"25"},"blue":{"small":"33","middle":"35","large":"9","max_large":"30"},"green":{"small":"34","middle":"30","large":"19","max_large":"3"},"orange":{"small":"9","middle":"15","large":"29","max_large":"18"}};
var _color_value;
var _size_value;
var _store_value;
$("#select_color div").click(function () {
$("#select_color div").attr("class","/bb");
$(this).attr("class","border");
_color_value = $(this).attr("date-value");
change_span_value()
});
$("#select_size div").click(function () {
$("#select_size div").attr("class","a");
$(this).attr("class","b");
_size_value = $(this).attr("date-value");
change_span_value()
});
function change_span_value() {
var _value = _json[_color_value][_size_value];
if (_value != undefined) {
$("#span_store").text(_value+"件");
}
}
});
// --></mce:script>
<body>
<div style="width:100%;margin:10px;" id="select_color">
<div style="background-color:red;cursor:pointer;" mce_style="background-color:red;cursor:pointer;" date-value="red">Red</div>
<div style="background-color:blue;cursor:pointer;" mce_style="background-color:blue;cursor:pointer;" date-value="blue">Blue</div>
<div style="background-color:green;cursor:pointer;" mce_style="background-color:green;cursor:pointer;" date-value="green">Green</div>
<div style="background-color:orange;cursor:pointer;" mce_style="background-color:orange;cursor:pointer;" date-value="orange">Orange</div>
</div>
<div style="width:100%;margin:10px;" id="select_size">
<div class="a" date-value="small">S</div>
<div class="b" date-value="middle">M</div>
<div class="a" date-value="large">L</div>
<div class="a" date-value="max_large">XL</div>
</div>
<div style="width:100%;margin:10px;text-align:left;" id="select_store">
庫(kù)存:(<span id="span_store">1000件</span>)
</div>
<div style="border:2px solid;width:100px;height:100px;background-color:gray"></div>
</body>
</html>
更多關(guān)于jQuery操作json相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《jQuery操作json數(shù)據(jù)技巧匯總》
希望本文所述對(duì)大家jQuery程序設(shè)計(jì)有所幫助。
- jquery.pagination +JSON 動(dòng)態(tài)無(wú)刷新分頁(yè)實(shí)現(xiàn)代碼
- Java Servlet生成JSON格式數(shù)據(jù)并用jQuery顯示的方法
- 使用Jquery+Ajax+Json如何實(shí)現(xiàn)分頁(yè)顯示附JAVA+JQuery實(shí)現(xiàn)異步分頁(yè)
- 基于Jquery+Ajax+Json實(shí)現(xiàn)分頁(yè)顯示附效果圖
- jquery實(shí)現(xiàn)下拉菜單的二級(jí)聯(lián)動(dòng)利用json對(duì)象從DB取值顯示聯(lián)動(dòng)
相關(guān)文章
jQuery實(shí)現(xiàn)響應(yīng)鼠標(biāo)背景變化的動(dòng)態(tài)菜單效果代碼
這篇文章主要介紹了jQuery實(shí)現(xiàn)響應(yīng)鼠標(biāo)背景變化的動(dòng)態(tài)菜單效果代碼,涉及jquery鼠標(biāo)mouseover事件操作頁(yè)面元素屬性的相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-08-08
遮罩層點(diǎn)擊按鈕彈出并且具有拖動(dòng)和關(guān)閉效果(兩種方法)
實(shí)現(xiàn)點(diǎn)擊按鈕彈出遮罩層,點(diǎn)擊按鈕可以隨意拖動(dòng)和關(guān)閉。接下來(lái),通過(guò)本篇文章給大家介紹遮罩層點(diǎn)擊按鈕彈出并且具有拖動(dòng)和關(guān)閉效果,需要的朋友可以參考下2015-08-08
JQuery解析HTML、JSON和XML實(shí)例詳解
JQuery具有強(qiáng)大的解析數(shù)據(jù)的能力,本文詳細(xì)介紹HTML、JSON和XML格式的文件的數(shù)據(jù)如何解析2014-03-03
jQuery實(shí)現(xiàn)單擊按鈕遮罩彈出對(duì)話框效果(1)
這篇文章主要為大家詳細(xì)介紹了jQuery實(shí)現(xiàn)單擊按鈕遮罩彈出對(duì)話框,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-02-02
jquery處理checkbox(復(fù)選框)是否被選中實(shí)例代碼
這篇文章主要介紹了jquery處理checkbox(復(fù)選框)是否被選中實(shí)例代碼的相關(guān)資料,需要的朋友可以參考下2017-06-06
jQuery獲取節(jié)點(diǎn)和子節(jié)點(diǎn)文本的方法
本節(jié)主要介紹了jQuery如何獲取節(jié)點(diǎn)和子節(jié)點(diǎn)文本,下面有個(gè)示例,大家可以參考下2014-07-07
jQuery 操作option的實(shí)現(xiàn)代碼
js清空option之前清空option ,我的做法是遍歷現(xiàn)有option,將其每個(gè)子元素都置空即可。2011-03-03
利用javascript/jquery對(duì)上傳文件格式過(guò)濾的方法
jquery中對(duì)上傳文件格式過(guò)濾的方法,需要的朋友參考下。2009-07-07

