[jQuery] Re: jQuery works in one place but not another
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: > > > > $(document).ready(function () { >alert('this works'); > $('h2').fadeOut('slow'); > }); > > > 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 > > > > > > > > $(document).ready(function () { > > alert('this works'); > > }); > > > > function showFilterCalendar() { > > $('h2').fadeOut('slow'); > > > > // don't follow the link > > return false; > > } > > > > > > When the page loads, I get the alert box saying "this works." > > However, when I click a link like > onclick="javascript:return showFilterCalendar()">test, I get the > > infamous "$ is not a function" error. > > > > Ideas? >
[jQuery] Re: jQuery works in one place but not another
Ok, I think I found a way around the problem. Apparently one of the other scripts my institution uses was overwriting $ or something... Including the jQuery library at the end of the HTML file (while not proper) seems to get around it. 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 > > > > $(document).ready(function () { > alert('this works'); > }); > > function showFilterCalendar() { > $('h2').fadeOut('slow'); > > // don't follow the link > return false; > } > > > When the page loads, I get the alert box saying "this works." > However, when I click a link like onclick="javascript:return showFilterCalendar()">test, I get the > infamous "$ is not a function" error. > > Ideas?
[jQuery] Re: jQuery works in one place but not another
I just tried this change: $(document).ready(function () { alert('this works'); $('h2').fadeOut('slow'); }); 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 > > > > $(document).ready(function () { > alert('this works'); > }); > > function showFilterCalendar() { > $('h2').fadeOut('slow'); > > // don't follow the link > return false; > } > > > When the page loads, I get the alert box saying "this works." > However, when I click a link like onclick="javascript:return showFilterCalendar()">test, I get the > infamous "$ is not a function" error. > > Ideas?