Bug Tracker

Modify

Ticket #11424 (closed bug: invalid)

Opened 15 months ago

Last modified 15 months ago

$('.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:
Blocking: Blocked by:

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.

Change History

comment:1 Changed 15 months ago by timmywil

  • Priority changed from undecided to low
  • Resolution set to invalid
  • Status changed from new to closed
  • Component changed from unfiled to misc

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

comment:2 Changed 15 months ago by sm1215

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.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.