Javascript 如何在jQuery中添加内联样式?

Javascript 如何在jQuery中添加内联样式?,javascript,jquery,css,Javascript,Jquery,Css,是否可以在以下代码中内联div。trigger,并将其显示设置为block $('.trigger').toggle(function() { $('.greendiv').animate({'height': '300px', 'width': '400px'}, 200); }, function(){ $('.greendiv').animate({'height': '200px', 'width': '200px'}, 200); }); 您只需使用$('.trigger

是否可以在以下代码中内联div
。trigger
,并将其显示设置为block

$('.trigger').toggle(function() {
   $('.greendiv').animate({'height': '300px', 'width': '400px'}, 200);
}, function(){
   $('.greendiv').animate({'height': '200px', 'width': '200px'}, 200);
});
您只需使用
$('.trigger').css('display','block')

如果要在
toggle
函数中实现它,可以执行以下操作:

$('.trigger').toggle(function() {
    $(this).css('display', 'block');
    $('.greendiv').animate({'height': '300px', 'width': '400px'}, 200);
}, function(){
    $('.greendiv').animate({'height': '200px', 'width': '200px'}, 200);
    $(this).css('display', 'none');
});

“在下面的代码上”是什么意思?你是指
$('.trigger').toggle(function(){}.css('display','block')?JavaScript还是JQuery?您可能需要将相关标记放入:)