检索this.title属性的前2个字符,并调用相应的id [英] Retrieve first 2 characters of this.title attribute, and call corresponding id

查看:41
本文介绍了检索this.title属性的前2个字符,并调用相应的id的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to retrieve the first two characters of a link's title attribute, store it into a variable, and then call that variable as a function. In the code, where it says "#" + s, is where I want that value to be placed. Any ideas?

$(".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);

get the first 2 characters in the title: var s = $(this).attr("title").substr(0, 2);

这篇关于检索this.title属性的前2个字符,并调用相应的id的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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