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
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply 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: 56153
    
  13

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


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

Joined: Jan 10, 2002
Posts: 56153
    
  13

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: 56153
    
  13

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
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Adding jquery to a page
 
Similar Threads
rich:hotKey worked when using jQuery?
RE: Using jQuery with JSF 2.0's resource
Any hint of JQuery on struts2 tutorial, thanks!
JQuery not working
Not able to hide a sentence using jquery