我想通过id like和class like得到一个图像,我已经这样做了,但不能让它工作:
Recency<input type="checkbox" class="checkbox order-by" id="order_dateDESC"/>
<a href="javascript:void(0)">
<img class="order-by order-by-img" id="order_dateASC" src="icons/up-arrow.png" width="8" height="7" /></a>
<a href="javascript:void(0)">
<img class="order-by order-by-img desc" id="order_dateDESC" src="icons/down-arrow.png" width="8" height="7" /></a>
Popularity<input type="checkbox" class="checkbox order-by" id="order_popDESC"/>
<a href="javascript:void(0)">
<img class="order-by order-by-img" id="order_popASC" src="icons/up-arrow.png" width="8" height="7" /></a>
<a href="javascript:void(0)">
<img class="order-by order-by-img desc" id="order_popDESC" src="icons/down-arrow.png" width="8" height="7" /></a>
<script>
$('.order-by-img [id^="'+order_by.substring(0, 9)+'"]').toggle() ;
</script>当您单击复选框时,它将按默认顺序排序。当您单击向下或向上箭头时,它应该相应地排序,复选框起作用。我不能处理的是切换图像。
发布于 2013-01-14 15:24:36
删除空格:
$('.order-by-img[id^="'+order_by.substring(0, 9)+'"]').toggle() ;这个空间需要一个后代。
https://stackoverflow.com/questions/14314585
复制相似问题