jquery - 将 span ID 传递给 jQuery 变量 : not working

标签 jquery html css

jQuery(".tags").on('click',function(){ //to show a tagged pose
    var ids = $(this).attr('id');
    console.log(ids);

    var x_cord = $(this).attr('data-x');
    var y_cord = $(this).attr('data-y');

    alert($('#'+ids).length);
    $($(ids)).css({color:'gray'});

    $("#overshow").css({
        top: y_cord,
        left: x_cord,
        width:'100px',
        height:'100px',
        position:'absolute',
        border:'3px solid red'
    });

    $('#overshow').show('fast'); //.delay(1000).hide('slow');
});

这是我的一段代码。我收到“1”警报,但未应用 css 属性。

最佳答案

您忘记了 .css 调用中的 id 选择器:

$("#" + ids).css({color:'gray'});

关于jquery - 将 span ID 传递给 jQuery 变量 : not working,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22913301/

相关文章:

javascript - 隐藏子组件Vue中的主div

javascript - Angular JS 中的动态 View 是什么?

html - Flexbox "align-items: center"不适用于 Chrome 测试版

JQuery UI 菜单项阻止默认链接行为

javascript - Jquery:如何将 "selectable"值获取到 "Slider"函数中?

jquery-plugins - jQuery - 为什么 ajaxForm 绕过验证过程?

css - Django:Firefox 不使用加载的 CSS

JavaScript 相当于 jQuery 文档点击类

javascript - 如何在没有终端命令的情况下运行 Node js 应用程序

html - 宽度为预文本格式