jsp给循环列表的行通过class绑定事件

<td>
    <select  class="displayRank" rankid="${rank.id }" ranktype="${type }">
       <option value="1" <c:if test="${rank.displayRank == 1}">selected</c:if>>1</option>
       <option value="2" <c:if test="${rank.displayRank == 2}">selected</c:if>>2</option>
       <option value="3" <c:if test="${rank.displayRank == 3}">selected</c:if>>3</option>
       <option value="4" <c:if test="${rank.displayRank == 4}">selected</c:if>>4</option>
       <option value="5" <c:if test="${rank.displayRank == 5}">selected</c:if>>5</option>
   </select>
</td>
脚本代码
$(function(){
        $(".displayRank").change(function(){
            var param = "appid="+$(this).attr("rankid")+"&type="+$(this).attr("ranktype")+"&rank="+$(this).val();
            $.ajax({
                type:"post",
                url : "${ctx}/rank/changeDisRank",
                data: param,
                dataType:"json",
                success:function(data){
                    alert(data.message);
                    window.location.reload();
                }
            });
        });
});

 

posted on 2013-03-16 12:06  blues_qi  阅读(251)  评论(0编辑  收藏  举报

导航