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/