Javascript 使用jQuery输入3和更改CSS值
我的网站有问题。我有两个分区,左边是页面的主要内容,右边是一些文本。当其中一个div中有很多内容时,它的高度会比另一个div大。所以我尝试使CSS值相等,但它根本不起作用。我已经仔细检查了所有东西,代码,文件目录等等。我仍然没有发现错误。 这是我包含jQuery和JS文件的打字脚本代码:Javascript 使用jQuery输入3和更改CSS值,javascript,jquery,css,typo3,typoscript,Javascript,Jquery,Css,Typo3,Typoscript,我的网站有问题。我有两个分区,左边是页面的主要内容,右边是一些文本。当其中一个div中有很多内容时,它的高度会比另一个div大。所以我尝试使CSS值相等,但它根本不起作用。我已经仔细检查了所有东西,代码,文件目录等等。我仍然没有发现错误。 这是我包含jQuery和JS文件的打字脚本代码: # jQuery includeJSlibs.jquery.external = 1 includeJSlibs.jquery = http://ajax.googleapis.com/ajax/libs/jq
# jQuery
includeJSlibs.jquery.external = 1
includeJSlibs.jquery = http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js
# Javascript
includeJS.file1 = fileadmin/script.js
这是我的JS文件(script.JS):
编辑:差点忘了CSS代码:
#content {
position: relative;
background-color: #ffffff;
width: 550px;
min-height: 510px;
border: 2px solid #b7cdd4;
border-left-width: 2.5px;
border-bottom-width: 0px;
float: left;
}
#sidebar {
position: relative;
float: right;
width: 242px;
background-color: #ffffff;
min-height: 600px;
border: 2px solid #b7cdd4;
border-left-width: 2.5px;
border-bottom-width: 0px;
margin-top: -91px;
}
有人能帮我吗?非常感谢。您的
jquery
无效。应该是:
$(document).ready(function () {
var contentHeight = $('#content').css("height");
var sidebarHeight = $('#sidebar').css("height");
if (contentHeight > sidebarHeight) {
$('#sidebar').height(contentHeight - 110);
} else {
$('#content').height(sidebarHeight + 110);
}
});
(打开控制台,你会看到高度在那里)谢谢你的帮助,我从某人那里得到了一个新代码,他使用var contentHeight=parseInt($('#content/sidebar').css(“height”),10);这很好用。这篇文章不知怎么被删除了。。。
$(document).ready(function () {
var contentHeight = $('#content').css("height");
var sidebarHeight = $('#sidebar').css("height");
if (contentHeight > sidebarHeight) {
$('#sidebar').height(contentHeight - 110);
} else {
$('#content').height(sidebarHeight + 110);
}
});