var obj = document.getElementById("<开发者_如何学运维;%= tbUpdate.ClientID %>");
var colorid = obj.value;
$('.shade[colorId=colorid]').addClass('active');
the problem is with the colorId=colorid. I think jQuery thinks that it's string. How can I pass value from var colorid into selector?
$('.shade[colorId=' + colorid + ']');
If you want to use the value of colorId
you would need to pass a string to the jQuery selector using concatenation$('.shade[colorId=' + colorid + ']')
.
$('.shade[colorId=' + colorid + ']').addClass('active');
精彩评论