JQuery一点使用记录
http://www.cnblogs.com/bynet/archive/2009/12/07/1618650.html
设置选中属性的样式
HTML结构:
<dl>
<dt>商品颜色:</dt>
<dd>
<ul>
<#list goodsDetailVo.wholesaleSellerGoods.subGoods as sku>
<li><a href="javascript:" onclick="setPrdClr($(this))">${(sku.value)!""}</a></li>
</#list>
</ul>
</dd>
</dl>
JS : 先把同层级的所有样式清除,然后设置选中的元素的样式
function setPrdSize(sze){
sze.parent().parent().find("li").removeClass("current");
sze.parent().addClass("current");
}
在切换 显示 / 隐藏 页面元素的应用:
<tr style="display:none" class='hiddenRoom_www'>......</tr>
<tr style="display:none" class='hiddenRoom_www'>......</tr>
<tr style="display:none" class='hiddenRoom_www'>......</tr>
<tr style="display:none" class='hiddenRoom_www'>......</tr>
<tr style="display:none" class='hiddenRoom_www'>......</tr>
<tr style="display:none" class='hiddenRoom_www'>......</tr>
一个按钮控制这些元素的 "显示" / "隐藏" 状态 :
if($('.hiddenRoom_www:first").is(":hidden")){
$('.hiddenRoom_www').show();
$('#i_'+classname).html("▲");
}else{
$('.hiddenRoom_www').hide();
$('#i_'+classname).html("▼");
}
"_www:first" 读取到列表的第一个元素, .is(":hidden") 判断是不是隐藏状态. 然后做相应的处理 .
FORM 应用:
<form id="orderform" action="http://buyer.mall.woyo.com/getSellerGoodsSKU.action">
<input type="hidden" name="lSellerGoodsId" value="${goodsDetailVo.sellerGoodsId}" />
<input type="hidden" name="lSubGoodsId" value="${goodsDetailVo.subGoodsId}" />
<input type="hidden" name="lSpecCombinationId" />
<input type="hidden" name="nCount" />
<input type="hidden" name="nChannelId" value="5" />
<input type="hidden" name="strHttpUrl" value="http://biz.woyo.com/mall/shops/productdetail.action" />
</form>
JS :
function orderGoods(){
$("#orderform").find("input[name='nCount']").val($("#buyNum").val());
//alert($("#orderform").find("input[name='nCount']").val());
$("#orderform").submit();
}