Reputation: 177
In the code below, the line that is commented out: var displayPieces = displayWhole.split(" ");
Breaks what happens in .subMenuContent area. If I comment out just that line, it works just fine. Any ideas?
$(".subMenuHeader").each(function() {
var displayWhole = $(this).attr('display');
//var displayPieces = displayWhole.split(" ");
});
$(".subMenuContent").each(function() {
$(this).prepend('<div class="subMenuShineLeft"></div>' +
'<div class="subMenuShineRight"></div>');
});
Upvotes: 1
Views: 84
Reputation: 9379
Your problem is due to displayWhole
being undefined
.
If you want to fetch an element's display
from its style to check whether it's block
or none
, don't use attr
, use css
. Like this:
var displayWhole = $(this).css('display');
The .attr()
function will fetch you the attributes for an HTML element, alright. But display
is not a HTML attribute. It is always part of the style
attribute. Had you used:
var displayWhole = $(this).attr('style');
Then you'd have the whole style
as a string, for you to work on.
The .css()
jQuery function, on the other hand, exists so that you can get the parts of the style
attribute more easily ;)
Upvotes: 5