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

我试图检索链接的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 { } }); 

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

获取属性的前两个并根据它找到目标。

 $('.flow').click(function() { var first2 = $(this).attr('customatt').substr(0, 2); $('#' + first2).doSomething(); return false; });