Jquery条件div的宽度

标签 jquery jquery-selectors

我正在 drupal 中工作。我在 1 个容器 div 中有 2 个 float div。容器宽度为 1000px,其中包含 2 个 float div col1(宽度:700px)和 col2(宽度:300px)。在某些页面中,我不想要 col2,它是通过 page.tpl.php 中的 php 条件完成的

如果文档或容器 div 中没有可用的 div,我需要一种方法将 div id“col1”的宽度重写为 100%。

最佳答案

类似的东西?

if (!$("#col2").length) {
   $("#col1").css("width", "1000px");
}

关于Jquery条件div的宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5733974/

相关文章:

javascript - 更改不同轮播上的导航栏字体颜色

jquery - 如何使 jquery 中的弹出窗口不闪烁

javascript - Quill JS - 检查表单提交上的文本是否更改

javascript - 从 url 获取 'following' - domain.com/following#2

jquery - $(document) 和 $(location) 中调用的 "document"和 "location"是什么?

javascript - 为什么 qtip2 插件不能使用 HTML?

javascript - Backspace 删除整个 span 元素

JQuery nth Child div 子级

jquery-selectors - 使用 JQuery 选择器知道父 div id 通过 id 选择子 div

javascript - 获取唯一选择器 jQuery