javascript - JQ函数值传递问题

查看:65
本文介绍了javascript - JQ函数值传递问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

 $('.seeMoreProduct').click(function(){
            var seeMoreIndexNum = ($('.seeMoreProduct').index($(this)));
        });
        var $newDesignSection = $('#designer_detail_con');
        if($(".designer_ul").length > 0) {
            $(".designer_ul").on("click",".ui_scroll_con > li",function(){
                var $this = $(this);
                $.ajax({
                    url: $this.attr('dataUrl'),
                    dataType: 'html',
                    success: function(data){
                        $newDesignSection.html(data);
                    }
                });

            }).find('.designer_List').eq(seeMoreIndexNum).click();
        } 


希望能做获取到seeMoreIndexNum的值,('.designer_List').eq(seeMoreIndexNum)这里获取不到

解决方案

seeMoreIndexNum是个匿名函数的内部变量,你定义一个,跟当前代码同级作用域的变量好了

这篇关于javascript - JQ函数值传递问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆