我有一个动态生成的列表。
当我单击一条线时,我想切换背景颜色,比如说-red green yellow。例如,当 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>