手机
当前位置:查字典教程网 >编程开发 >Javascript教程 >jquery+json实现动态商品内容展示的方法
jquery+json实现动态商品内容展示的方法
摘要:本文实例讲述了jquery+json实现动态商品内容展示的方法。分享给大家供大家参考,具体如下:Example|xHTML1.0div{wi...

本文实例讲述了jquery+json实现动态商品内容展示的方法。分享给大家供大家参考,具体如下:

<!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 id="select_color"> <div mce_style="background-color:red;cursor:pointer;" date-value="red">Red</div> <div mce_style="background-color:blue;cursor:pointer;" date-value="blue">Blue</div> <div mce_style="background-color:green;cursor:pointer;" date-value="green">Green</div> <div mce_style="background-color:orange;cursor:pointer;" date-value="orange">Orange</div> </div> <div id="select_size"> <div date-value="small">S</div> <div date-value="middle">M</div> <div date-value="large">L</div> <div date-value="max_large">XL</div> </div> <div id="select_store"> 库存:(<span id="span_store">1000件</span>) </div> <div></div> </body> </html>

希望本文所述对大家jQuery程序设计有所帮助。

【jquery+json实现动态商品内容展示的方法】相关文章:

原生JS和JQuery动态添加、删除表格行的方法

jquery读取xml文件实现省市县三级联动的方法

JS动态增删表格行的方法

动态加载jQuery的方法

JS实现兼容各浏览器解析XML文档数据的方法

javascript实现dom动态创建省市纵向列表菜单的方法

jquery插件splitScren实现页面分屏切换模板特效

jQuery切换所有复选框选中状态的方法

javascript实现设置、获取和删除Cookie的方法

Jquery解析json字符串及json数组的方法

精品推荐
分类导航