Skip to main content

Bug Tracker

Side navigation

#11424 closed bug (invalid)

Opened March 01, 2012 03:09PM UTC

Closed March 01, 2012 03:26PM UTC

Last modified March 01, 2012 03:41PM UTC

$('.class') vs jQuery('.class') one returns null, the second returns the correct element

Reported by: sm1215 Owned by:
Priority: low Milestone: None
Component: misc Version: 1.7.1
Keywords: Cc:
Blocked by: Blocking:
Description

Summary explains it all, it was my understanding $ was a valid shortcut for jQuery, but this has had me stumped for some time. I only substituted jQuery in out of desperation. I am still fairly new to jQuery so if this is not the case, then please disregard this message. Here is my code:

<script>

(function(){

Doesn't work

var $des = $('.description');

var $des = jQuery('.description');

console.log($des);

})();

</script>

My description class is inside a div, nested in a list, so maybe that could have been causing some problems? It just seemed strange to me that one method works and the other doesn't. Anyways, as I've said, I'm still relatively new, so there may be something I have missed. Thought it was worth mentioning though.

Attachments (0)
Change History (2)

Changed March 01, 2012 03:26PM UTC by timmywil comment:1

component: unfiledmisc
priority: undecidedlow
resolution: → invalid
status: newclosed

You are either in noConflict mode or something has overwritten $. Please ask for support on the forums or in the #jquery irc channel.

Changed March 01, 2012 03:41PM UTC by sm1215 comment:2

Yes, I had lightbox also running, and after disabling it, it works fine. I had not considered that something was overwriting $. My apologies for any time wasted. I didn't even mean to post this yet, I was trying to preview it, and had trouble, it was marked as spam? I still wanted to read through the guidelines and I was trying to get it running in jsFiddle. Lol... ughh I am unfamiliar with the ticket system, thank you for your response.