我想在我的jQuery中为我在页面上使用的图表设置一定的宽度。我使用类.sparkline-width
在样式表中设置了宽度。我怎样才能在我的jQuery中调用这个类?
HTML
<div id="sparkline-1" class="sparkline sparkline-width"></div>
的jQuery
$("#sparkline-1, #sparkline-3, #sparkline-5").sparkline([5,6,7,9,9,5,3,2,2,4,6,7], {
type: 'line',
spotColor: '#990000',
minSpotColor: '#990000',
maxSpotColor: '#990000',
width:
height: '25px',
});
答案 0 :(得分:0)
您可以使用width():
$('.sparkline-width').width("Your width here");
根据您的评论,您可以为元素添加新类:
$("p").addClass("newClass");
然后在你的css中引用它:
.newClass {
/* Your styles here */
}