检索this.title属性的前2个字符,并调用相应的id

dyl*_*494 1 jquery

我试图检索链接的title属性的前两个字符,将其存储到变量中,然后将该变量作为函数调用.在它所说的代码中,"#" + s我希望放置该值.有任何想法吗?

$(".flow").click(function() {
    if (labelstatus = 1) {
        $('.rmflow a,.weflow a,.scflow a,.coflow a,.wcflow a').css({
            color: "#b7b7b7"
        });

        $("." + this.title + " a").css({
            color: "#3e3e3e"
        });

        $("#" + this.title).parent().animate({
            opacity: '1'
        });

        $('.initiate').animate({
            opacity: '.4'
        }, 100);

        // variable to be put in the below selector
        $("#" + s).parent().animate({
            opacity: '1'
        });

        $('.info').fadeOut(200);
        $("#" + this.title).fadeIn(1000);
        return false;
    }
    else {
    }
});
Run Code Online (Sandbox Code Playgroud)

Mar*_*lie 15

获取标题中的前2个字符: var s = $(this).attr("title").substr(0, 2);