Why can't I change the CSS of this element?
$("div.example ul li").mouseover(function () {
var ul_teirs = $("div.example ul li").find('ul');
var second_teir = ul_teirs[0];
var third_teir = ul_teirs[1];
second_teir.css({
...
});
});
error I'm getting:
Uncaught TypeError: Object #<HTMLUListElement> has no method 'css'
Why can't I change the CSS of this element?
$("div.example ul li").mouseover(function () {
var ul_teirs = $("div.example ul li").find('ul');
var second_teir = ul_teirs[0];
var third_teir = ul_teirs[1];
second_teir.css({
...
});
});
error I'm getting:
Uncaught TypeError: Object #<HTMLUListElement> has no method 'css'
Share
Improve this question
edited Sep 24, 2011 at 5:00
Yi Jiang
50.1k16 gold badges138 silver badges136 bronze badges
asked Sep 24, 2011 at 4:58
dgamma3dgamma3
2,3714 gold badges27 silver badges48 bronze badges
2 Answers
Reset to default 15When you use []
to access an item in a jQuery array, you get the DOM element, not a jQuery object, so it doesn't have any jQuery methods.
Try .eq()
instead:
var second_tier = ul_tiers.eq(0);
second_tier.css({ ... });
(Note that I changed the spelling of "tier" in the variable name. Sorry, I can't help myself.)
Try
var second_teir = ul_teirs.eq(0);
var third_teir = ul_teirs.eq(1);
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1739468072a4128655.html
评论列表(0条)