jq 给循环出来的列表项加点击事件

1,922 阅读1分钟
  • 例如用模板渲染出来的列表项,首先拿到页面上已有的id,给已有id绑定事件,找到要操作的元素对象,加方法
$(function () {
            $('#scrollLoadContent').on('click',".pull-right",function () {
                if($(this).css('display') == '-webkit-box'){
                    $(this).css('display','inline-block');
                    $(this).find('.trange').css({'transform':'rotate(315deg)','bottom':'-2px','top':'inherit'});
                }else {
                    $(this).css('display','-webkit-box');
                    $(this).find('.trange').css({'transform':'rotate(135deg)','bottom':'inherit','top':'40px'});
                }
            })
        })