javascript - 检查 style="height: 0px"
问题描述
我有一些元素通过脚本分配了内联样式高度。我需要检查一个元素是否具有以下内容:style="height: 0px"
<div class="myEm" style="height: 30px">...</div>
<div class="myEm" style="height: 10px">...</div>
<div class="myEm" style="height: 0px">...</div>
jQuery
$(".myEm").each(function(){
if ($(this).attr("style") == "0px") {
$(this).css("border-color", "red");
}
});
解决方案
以下作品:
$(".myEm").each(function() {
if (this.style.height == "0px") {
$(this).css("border-color", "red");
}
});
推荐阅读
- html - 停止img元素html的溢出
- prolog - 为什么 Prolog 规则有时会以类似的输入返回 False?
- python - Python:编写搜索结果 URL
- laravel - 无法使用 Laravel 在 Heroku 上存储文件
- css - 设置问号点颜色?可能的?
- docker - 使用 Google Cloud Platform 的 Gitlab-CI 自动缩放未按预期生成
- php - 颁发令牌和刷新令牌:Laravel /jwt
- emacs - Emacs Prelude:如何禁用 perl 文件的 smartparens?
- dart - Android Manifest com.apptreesoftware.barcodescan 中的 Flutter 未解析包
- javascript - 从嵌套元素中检索链接