我希望通过id和类似的方式获取图像,我已经完成了但无法使其工作:
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>
当您单击该复选框时,它会按默认排序排序。当您单击向下或向上箭头时,它应相应地排序,复选框正在工作。我无法管理的是切换图像。我怎样才能切换。
答案 0 :(得分:1)
删除空格:
$('.order-by-img[id^="'+order_by.substring(0, 9)+'"]').toggle() ;
空间要求后代。