更改jQuery中div的高度
我想使用jQuery更改所有带有特定更改jQuery中div的高度,jquery,css,html,Jquery,Css,Html,我想使用jQuery更改所有带有特定类的div标记的高度。 我已经使用CSS成功地设置了高度,但是我想从jQuery中更改它 我尝试了以下代码: $('.slide-container').css({ "height": 200 + "px !important" }); $('.slide-container').height(200); $('.slide-container').css({ "height": 200 + "px" }); 这是设置原始高度的CSS .sli
类的div
标记的高度。
我已经使用CSS成功地设置了高度,但是我想从jQuery中更改它
我尝试了以下代码:
$('.slide-container').css({ "height": 200 + "px !important" });
$('.slide-container').height(200);
$('.slide-container').css({ "height": 200 + "px" });
这是设置原始高度的CSS
.slide-container { height:300px !important; }
JQuery有一个内置的设置高度的功能
将高度应用于div标记,该div是从中生成的
当高度来自数据库时,使用某个类的jquery!
var newHeight=yourHeightFromDB;
$(函数(){
$('.slide container')。高度(新高度);
});
更改css中的行
高度:300px!重要的代码>
到
高度:300px代码>
此语句基本上不允许动态设置高度。
您的Jquery代码运行良好。
其他人也可以使用此代码
$(document).ready(function() {
$('.slide-container').height(500);
});
为什么你的问题标题有c#
?为什么你要设置!重要信息
在您的类声明中?除非你知道自己在做什么,否则你真的不应该使用它…@user1167870提供的任何答案都能帮到你吗?
<div class="slide-container">
apply height to a div tag ,that div is generating from
jquery with some class, when height comes from database!
</div>
<script type="text/javascript">
var newHeight = yourHeightFromDB;
$(function() {
$('.slide-container').height(newHeight);
});
</script>
$(document).ready(function() {
$('.slide-container').height(500);
});