File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Adding jquery to a page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Adding jquery to a page" Watch "Adding jquery to a page" New topic
Author

Adding jquery to a page

Srikkanth Mohanasundaram
Ranch Hand

Joined: Feb 07, 2007
Posts: 185
Hello all,

I have HTML page which contains some javascript functions , now I try to include jquery.js file in this page. I'm not adding this in the head of the HTML.But when i add this, the whole page is not displayed.



I remove the include, and the page is rendered again. Is jquery working on the HTML elements on page load? Or should it be always added to the head of the HTML doc?

Thanks,
Srikkanth
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

The syntax is invalid. <script> tags cannot be self-closing.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

And yes, the script should be in the head element.
Srikkanth Mohanasundaram
Ranch Hand

Joined: Feb 07, 2007
Posts: 185
Thanks for pointing out the mistake Bear. I changed it to this, and now it is working. But why do you say it should be in the HEAD?



Thanks,
Srikkanth
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

Convention, and to be sure that it's loaded before the body.
Srikkanth Mohanasundaram
Ranch Hand

Joined: Feb 07, 2007
Posts: 185
Thanks a lot for your help
 
 
subject: Adding jquery to a page
 
Similar Threads
RE: Using jQuery with JSF 2.0's resource
Any hint of JQuery on struts2 tutorial, thanks!
rich:hotKey worked when using jQuery?
JQuery not working
Not able to hide a sentence using jquery