0

我想通过 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>

当您单击复选框时,它会按默认顺序排序。当您单击向下或向上箭头时,它应该相应地排序,复选框正在工作。我无法管理的是切换图像。我该如何进行切换。

4

1 回答 1

1

删除空间:

$('.order-by-img[id^="'+order_by.substring(0, 9)+'"]').toggle() ;

空间要求后代。

于 2013-01-14T07:24:36.403 回答