html代码片段:
<tr> <td class="td1">图片分类</td> <td class="td2"> <select class="c333 sel" name="type" id="type_p"><!--js通过此select选择下面的一个li显示,另一个隐藏--> <option value="1">轮播图</option> <option value="2">展示图</option> </select> </td> </tr> <li class="clearfix" id="li_0"> <div class="gamedata-size fl">{$item.width}*{$item.height}</div> <div class="gamedata-upload fl" style="width:250px"> <div> <div class="fieldset flash" id="fsUploadProgress0"></div> <span id="spanButtonPlaceHolder0"></span> <input type="hidden" name="pic_url0" id="imgurl0" value=""> <input type="hidden" name="width0" value="{$item.width}"> <input type="hidden" name="height0" value="{$item.height}"> <input type="hidden" name="extension0" value="{$item.extension}"> <input type="hidden" name="info0" value="{$item.info}"> <input type="hidden" name="key_select" value="0"> <div class="gamedata2-modi" id="img0"></div> </div> <p class="error"></p> </div> <div class="gamedata-box fl"> <h4 class="gamedata2-h4-title">示例要求</h4> <dl class="gamedata2-dl"> <dt> <img src="{$item.src}" height="{$item.height}" width="{$item.width}" > </dt> <dd> <p class="gamedata2-img-txt clearfix"> <span class="gamedata2-img-txt-left fl">图片格式:</span> <span class="gamedata2-img-txt-right fl">{$item.extension}</span> </p> <p class="gamedata2-img-txt h96"> <span class="gamedata2-img-txt-left fl">构图要求:</span> <span class="gamedata2-img-txt-right fl">{$item.info}</span> </p> </dd> </dl> </div> </li> <li class="clearfix" id="li_1" style="display: none;"> <div class="gamedata-size fl">{$item.width}*{$item.height}</div> <div class="gamedata-upload fl" style="width:250px"> <div> <div class="fieldset flash" id="fsUploadProgress1"></div> <span id="spanButtonPlaceHolder1"></span> <input type="hidden" name="pic_url1" id="imgurl1" value=""> <input type="hidden" name="width1" value="{$item.width}"> <input type="hidden" name="height1" value="{$item.height}"> <input type="hidden" name="extension1" value="{$item.extension}"> <input type="hidden" name="info1" value="{$item.info}"> <div class="gamedata2-modi" id="img1"></div> </div> <p class="error"></p> </div> <div class="gamedata-box fl"> <h4 class="gamedata2-h4-title">示例要求</h4> <dl class="gamedata2-dl"> <dt> <img src="{$item.src}" height="{$item.height}" width="{$item.width}" > </dt> <dd> <p class="gamedata2-img-txt clearfix"> <span class="gamedata2-img-txt-left fl">图片格式:</span> <span class="gamedata2-img-txt-right fl">{$item.extension}</span> </p> <p class="gamedata2-img-txt h96"> <span class="gamedata2-img-txt-left fl">构图要求:</span> <span class="gamedata2-img-txt-right fl">{$item.info}</span> </p> </dd> </dl> </div> </li>
js代码片段:
<script type="text/javascript"> $("#type_p").change(function(){ var v = $("#type_p").val(); if(v == 1){ $("#li_0").show(); $("#li_1").hide(); }else if(v == 2){ $("#li_0").hide(); $("#li_1").show(); } }); /*查找可见元素的子元素*/ var key = $("li:visible").find("input[name=‘key_select‘]").val();//重点在这里: li:visible //操作var </script>
时间: 2024-11-05 11:34:12