Question

I am trying to learn jQuery from a book. There are examples in it, but when I try to do the same, the result is not the same. when I run

$("p");

in Firebug(1.12.8) console, it shows just one paragraph even though there are 4 paragraphs on the page, but in the book the result is a set of all 4 paragraphs. Is this a problem with Firebug version?

Update:

Here is my HTML code:

<!doctype html>
<html>
<head>
    <meta charset='utf-8'>
    <title>Test | Pro PHP and 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 src='http://www.google.com/jsapi' />
    <script>
    google.load("jquery", "1.4.2");
    </script>
</body>
</html>

and I am using Firefox 26 and jquery 1.4.2(as in the book). Also, using jQuery() instead of $() did not work.

Update:

Ok, I found that it was a problem about my html. I shouldn't have used the self closing script tag. No problem, now.

Was it helpful?

Solution

Ok, I found that it was a problem about my html. I shouldn't have used the self closing script tag. No problem, now. Btw, thank @Sebastian for remembering me to accept my own answer.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top