开发者

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&g开发者_StackOverflow中文版t;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>


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


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜