0

我有这个代码:

$("div[id^='intCell']").mouseover(function() {
    $(this).css({ "border:","1px solid #ff097c"});
}).mouseout(function() {
    $(this).css({"border:","1px solid #000"});
})

但我无法让它工作!在 html 中有一个由 php 生成的具有 intCell_1、intCell_2 等 id 的 div 列表。有什么想法吗?

4

2 回答 2

1

更新:

您可以使用命令“hover”代替“mouseover”和mouseout”,并在属性选择器中使用星号:

例子:

$("div[id*='intCell']").hover(function() {
 $(this).css({border:"1px solid #ff097c"});
},
function() {
 $(this).css({border:"1px solid #000000"});
});
于 2009-05-14T16:06:36.393 回答
0

您的 CSS 对象文字语法不正确!

它应该是:

$("div[id^='intCell']").mouseover(function() {
        $(this).css({ "border": "1px solid #ff097c"}); // <-- This syntax was wrong
}).mouseout(function() {
        $(this).css({"border": "1px solid #000"}); // <-- This syntax was wrong
})

工作示例: http: //jsbin.com/iyoba(可通过http://jsbin.com/iyoba/edit编辑)

于 2009-05-14T16:20:18.060 回答