【发布时间】:2012-08-15 06:09:54
【问题描述】:
我很难找到解决此问题的方法:我正在尝试使某些 CSS 元素(如 border-color 或 a)在鼠标悬停时更改不同的颜色。我正在使用 DOM 来逃避 iframe 限制并在边界之外更改代码。到目前为止,这是我的代码:
<script type="text/javascript">
window.parent.document.getElementById("screenshots").style.backgroundImage="url(bg.png)";
window.parent.document.getElementById("screenshots").style.color="#000";
window.parent.document.getElementById("description_container").style.marginBottom="-4px";
$(window.parent.document.getElementById("screenshots")).children("a").each(function (i, o) {
$(o).children("img").each(function (i, img) {
$(img).css({
/* "border": "5px", */
"border-color": "rgba(119, 94, 4, .75)",
"border-style": "solid",
"border-radius": "10px",
"opacity": "0.9",
});
});
});
例如,上面写着"border-color": "rgba(119, 94, 4, .75)", 我希望它改变悬停时的颜色。
谢谢!
【问题讨论】:
-
在 jQuery 中使用
.hover(function(){}, function(){}),对于 JavaScript,使用onmouseover() -
感谢您的快速回复!我对如何在我的代码中实现它感到困惑。你能进一步解释一下我在这种情况下如何使用 jQuery 吗?
标签: javascript jquery html css dom