Uncaught TypeError: Cannot read property 'guid' of undefined
I have the following JQuery code:
- $("#menu-247 > a, #menu-213 > a, #menu-214 > a, #menu-215 > a, #menu-216 > a, #menu-218 > a, #menu-219 > a").addClass("mainLevel");
- /*$(".mainLevel").each(function (i) {
- $(this).before('<div id="' + $(this).parent().attr("id") + '-behind"> </div>');
- $(this).prev().css({
- width: $(this).css("width"),
- height: $(this).css("height"),
- position: "absolute",
- top: "0",
- left: $(this).parent().css("left"),
- zIndex: "5",
- display: "none",
- backgroundColor: "blue"
- });
- $(this).css({
- position: "relative",
- zIndex: "10"
- });
- });*/
-
- $(".mainLevel").hover(function() {
- alert('test');
- });
And I receive the error "Uncaught TypeError: Cannot read property 'guid' of undefined" in Google Chrome.
I thought it had to do with the fact that the event handler was trying to be added before the DOM was modified. But then I tried simply this:
- $("#menu-247 > a, #menu-213 > a, #menu-214 > a, #menu-215 > a, #menu-216 > a, #menu-218 > a, #menu-219 > a").hover(function() {
- alert('test');
- });
And still received the error. I removed all the "> a" so I simply had a list of ids and the error was still there. Even when I only have one id listed, the error comes up! It also seems to be any element.
But if I just try the alert part, everything works.
Any ideas? Thanks!