When you call $(document).ready, the $ is equal to jQuery, so it works.
You're passing it a callback function to be executed when the DOM is ready.
By that time another library has loaded and overwritten the $. For possible
work-arounds see

http://docs.jquery.com/Using_jQuery_with_Other_Libraries

Especially the last few bullet points.

- Richard

On Fri, Jul 11, 2008 at 2:19 PM, Josh <[EMAIL PROTECTED]> wrote:

>
> I just tried this change:
>
> <script type="text/javascript" src="/scripts/jquery.js"></script>
> <script type="text/javascript">
> $(document).ready(function () {
>    alert('this works');
>     $('h2').fadeOut('slow');
> });
> </script>
>
> Same problem: "$ is not a function."  The alert works, but the
> fadeOut() doesn't.  Why would it work for $(document) but not the
> other?
>
> On Jul 11, 11:38 am, Josh <[EMAIL PROTECTED]> wrote:
> > I'm observing some strange behavior with jQuery 1.2.6 today.  I've got
> > this in my <head>
> >
> >     <script type="text/javascript" src="/scripts/jquery.js"></script>
> >     <script type="text/javascript">
> >     $(document).ready(function () {
> >         alert('this works');
> >     });
> >
> >     function showFilterCalendar() {
> >         $('h2').fadeOut('slow');
> >
> >         // don't follow the link
> >         return false;
> >     }
> >     </script>
> >
> > When the page loads, I get the alert box saying "this works."
> > However, when I click a link like <a href="#"
> > onclick="javascript:return showFilterCalendar()">test</a>, I get the
> > infamous "$ is not a function" error.
> >
> > Ideas?
>

Reply via email to