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)容感興趣的讀者可查看本站專(zhuān)題:《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序列化表單成對(duì)象的簡(jiǎn)單實(shí)現(xiàn)
下面小編就為大家?guī)?lái)一篇jQuery序列化表單成對(duì)象的簡(jiǎn)單實(shí)現(xiàn)。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2016-11-11jQuery實(shí)現(xiàn)手機(jī)上輸入后隱藏鍵盤(pán)功能
最近做了這樣一個(gè)功能,讓用戶輸入手機(jī)發(fā)送驗(yàn)證碼,輸完11位手機(jī)號(hào)后,自動(dòng)隱藏鍵盤(pán)。下面通過(guò)本文給大家分享實(shí)現(xiàn)方法,一起看看吧2017-01-01jquery實(shí)現(xiàn)簡(jiǎn)易驗(yàn)證插件封裝
這篇文章主要為大家詳細(xì)介紹了jquery實(shí)現(xiàn)簡(jiǎn)易驗(yàn)證插件的封裝,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-09-09基于jquery實(shí)現(xiàn)的樹(shù)形菜單效果代碼
這篇文章主要介紹了基于jquery實(shí)現(xiàn)的樹(shù)形菜單效果代碼,實(shí)例分析了jquery基于鼠標(biāo)事件動(dòng)態(tài)改變頁(yè)面元素屬性的技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-09-09使用jquery獲取網(wǎng)頁(yè)中圖片高度的兩種方法
使用jquery獲取網(wǎng)頁(yè)中圖片的高度其實(shí)很簡(jiǎn)單,目前有兩種不錯(cuò)的方法可以實(shí)現(xiàn),下面為大家詳細(xì)介紹下,有所疑惑的你可以參考下2013-09-09jQuery實(shí)現(xiàn)360°全景拖動(dòng)展示
360全景就是視角超過(guò)人的正常視角的圖像,而我們這里說(shuō)的全景特指水平視角360度,垂直視角180度的圖像。可以全景空間里進(jìn)行切換,達(dá)到瀏覽各個(gè)不同場(chǎng)景360全景展示的目的。2015-03-03jQuery實(shí)現(xiàn)鼠標(biāo)滑過(guò)商品小圖片上顯示對(duì)應(yīng)大圖片功能【測(cè)試可用】
這篇文章主要介紹了jQuery實(shí)現(xiàn)鼠標(biāo)滑過(guò)商品小圖片上顯示對(duì)應(yīng)大圖片功能,涉及jQuery事件響應(yīng)、元素遍歷及屬性動(dòng)態(tài)操作相關(guān)實(shí)現(xiàn)技巧,需要的朋友可以參考下2018-04-04