Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何找到具有样式的div元素?_Javascript_Html - Fatal编程技术网

Javascript 如何找到具有样式的div元素?

Javascript 如何找到具有样式的div元素?,javascript,html,Javascript,Html,如何按样式查找div元素 我在IE6中“查看源”,并具有以下功能: ...an><div id="lga" style="height:231px;margin-top:-22px"><img alt="Google"... 这个问题不是很清楚。这就是你要找的吗 var div_style = document.getElementById('lga').style; 你为什么想按它的风格来做这个节目?通过ID获取它要简单得多 标准JavaScript: docume

如何按样式查找div元素

我在IE6中“查看源”,并具有以下功能:

...an><div id="lga" style="height:231px;margin-top:-22px"><img alt="Google"...

这个问题不是很清楚。这就是你要找的吗

var div_style = document.getElementById('lga').style;

你为什么想按它的风格来做这个节目?通过ID获取它要简单得多

标准JavaScript:

document.getElementById("lga");
如果使用jQuery:

$("#lga");
使用


如果您真的想按样式查找元素(我不推荐)

通过jQuery可以做到这一点

// jQuery attr equal value selector [1]
$('[style="{your_style_value}"]'); 

// in your case
$('[style="height:231px;margin-top:-22px"]')
[1]


希望获得以下帮助:)

真正的WTF是您正在使用Internet explorer 6,尽管Internet explorer 8是windows 7的标准,Internet explorer 9及以上版本是9的标准,即使你有一个旧版本的windows,仍然有firefox和Chrome,它们是>Internet explorer 6。

你正在尝试根据div元素的样式搜索它吗?你还在认真使用IE6吗?
// jQuery attr equal value selector [1]
$('[style="{your_style_value}"]'); 

// in your case
$('[style="height:231px;margin-top:-22px"]')