gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 23:40:53 25 4
gpt4 key购买 nike

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/

25 4 0
文章推荐: javascript - 制作带有链接的可点击
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com