This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Having Problems with Jquery. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "Having Problems with Jquery." Watch "Having Problems with Jquery." New topic
Author

Having Problems with Jquery.

Michael Hubele
Ranch Hand

Joined: Dec 17, 2005
Posts: 182
Hi

its been a while since I used jquery so I am trying to do a simple thing that when you click a button it pops up an alert box.

I have this




When I press the button nothing runs.
Joe Lemmer
Ranch Hand

Joined: Oct 24, 2008
Posts: 171
Hi Michael,

I have copied and pasted your code and it runs fine for me in IE, Firefox and Opera.

Are you sure you have the jquery-1.3.1.min.js as pointed to in your head, or do you have the normal jquery-1.3.1.js?

That's all I can think of really

Cheers

Joe Lemmer


OCPJP 85%
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15357
    
    6
You are calling the code before the element is rendered. You need to either use dom ready or put the code after the button.

Eric
Michael Hubele
Ranch Hand

Joined: Dec 17, 2005
Posts: 182
Joe Lemmer wrote:Hi Michael,

I have copied and pasted your code and it runs fine for me in IE, Firefox and Opera.

Are you sure you have the jquery-1.3.1.min.js as pointed to in your head, or do you have the normal jquery-1.3.1.js?

That's all I can think of really

Cheers

Joe Lemmer


I think I figured out the problem. I have that intellsense file and it is so picky. If you have the jquery script before the intellsense file at run time I don't know what happen it does not work. If you move the file up so the intellisense file is above the jquery script it works.

I don't remember it every being that pick before.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56183
    
  13

Eric Pascarello wrote:You are calling the code before the element is rendered.
Actually he's not. The code is in a jQuery ready handler.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56183
    
  13

jQuery itself is a good on-page citizen, making sure that it doesn't clobber other libraries (even going so far as to have a mechanism to relinquish the $ name to other libraries).

Other libraries are generally not so friendly about sharing the page.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Having Problems with Jquery.
 
Similar Threads
Need help with Jquery
jquery, hover and unbind
How Do I Access All of the src Attributes of All of the Images in a Web Page?
Cannot see the JavaScript code I wrote when I hit script tab on firebug :(
Is there something better then event.pageX/Y?