0
我有一個動態生成列表。jquery切換動態列表三態
當我點擊一行我想切換背景顏色讓我們說,紅綠黃。例如,當id不動態時,我已經看到了答案。
<ul data-role="listview" id="my-listview" >
<c:forEach var="line" items="${tl.reqs}">
<li id="lnk"><a href="#" onclick= '
$(this).toggle(function(){
$(this).css("background-color","green");},
function(){
$(this).css("background-color","red");},
function(){
$(this).css("background-color","yellow");}
);'
${line.name}</a>
</li>
</c:forEach>