mdgrech
mdgrech

Reputation: 955

Basic help using Firebug

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>

Upvotes: 1

Views: 1030

Answers (3)

Nealv
Nealv

Reputation: 6884

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

Upvotes: 2

kander
kander

Reputation: 4286

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 );
}

Upvotes: 1

Coding Flow
Coding Flow

Reputation: 21881

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

Upvotes: 0

Related Questions