1

Just starting using the Firebug console. I have a test script which I'll post below. I open up the Firebug console and type $("p"); this returns null. Its my understanding it should return all my p elements ie p, p.foo, p, p#bar. A conflict maybe or am I just using the console incorrectly?

<!DOCTYPE html>
<html>
<head>
 <title>Testing jQuery</title>
</head>
<body>
 <p>Hello World!</p>
 <p class="foo">Another paragraph, but this one has a class.</p>
 <p><span>This is a span inside a paragraph.</span></p>
 <p id="bar">Paragraph with an id.
 <span class="foo">And this sentence is in a span.</span>
 </p>
 <script type="text/javascript" src="http://www.google.com/jsapi"></script>
 <script type="text/javascript"
 google.load("jquery", "1.4.2");
 </script>
</body>
</html>
sberry
133k20 gold badges145 silver badges171 bronze badges
asked Jul 20, 2010 at 15:28
3
  • 2
    Are you accidentally missing the closing > in your script that is loading jquery, or is that a typo? Commented Jul 20, 2010 at 15:31
  • Hmm quick sanity check here, the missing ">" on the line above google.load("jquery", "1.4.2");... is that a copy and paste error? Commented Jul 20, 2010 at 15:31
  • It was the missing closing bracket on the script tag. Thanks guy. Interesting side note: it worked for me by adding a $. ie $$("p") correctly returned the results even w/ the missing bracket. Go figure :) Commented Jul 20, 2010 at 15:48

3 Answers 3

2

What you used is an ID selector. If you have a selector with an id u should use $("ID").

What you want is an array of css selectors-> then you should use $$("selector") -> in your case: $$("p")

more information is to be found here

http://www.joehewitt.com/software/firebug/docs.php

I hope this helped :D

answered Jul 20, 2010 at 15:42
Sign up to request clarification or add additional context in comments.

2 Comments

Nealv - interesting! It appears both Firebug and jQuery use the dollar-function as a selector. It definitely explains why the topic starter was seeing the result he did, although the solution he was looking for was more regarding figuring out whether or not jQuery was loaded. Thanks for adding this answer, learned something today!
It was my understanding that he needed help with firebug. anyway glad to be of service. I learn lots here every day :)
1

You're using the console correctly. Even if jQuery can't find any results, it should return an empty object, not null.

Could you console.log($); to see if jQuery is loaded?

That should result in the jQuery function being returned:

function ( selector, context ) {
 // The jQuery object is actually just the init constructor 'enhanced'
 return new jQuery.fn.init( selector, context );
}
answered Jul 20, 2010 at 15:32

Comments

0

Yes you are using the console correctly, when i open firebug and type $("p") it returns everry p element in the DOM.

answered Jul 20, 2010 at 15:32

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.