I, for some reason, can\'t change the zIndex of an element using jQuery. I\'ve searched all of this website and Google but couldn\'t find the right answer. I am trying to
That's invalid Javascript syntax; a property name cannot have a -
.
Use either zIndex
or "z-index"
.
zIndex
is part of javaScript notation.(camelCase)
but jQuery.css uses same as CSS syntax.
so it is z-index
.
you forgot .css("attr","value"). use ' or " in both, attr and val. so,
.css("z-index","3000");
Setting the style.zIndex
property has no effect on non-positioned elements, that is, the element must be either absolutely positioned, relatively positioned, or fixed.
So I would try:
$(this).parent().css('position', 'relative');
$(this).parent().css('z-index', 3000);
$(this).parent().css('z-index',3000);
because your jQuery code is wrong. Correctly would be:
var theParent = $(this).parent().get(0);
$(theParent).css('z-index', 3000);