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 Falling in love with jQuery? 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 "Falling in love with jQuery?" Watch "Falling in love with jQuery?" New topic
Author

Falling in love with jQuery?

Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3704
    
    5

On the book website, it says "You'll fall in love with it when you see 20 lines of code reduced to three.". Could you give an example or two of this? The description sounds appealing but I'd like more substance. What can jQuery do that would be a huge pain to do without?


My Blog: Down Home Country Coding with Scott Selikoff
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61095
    
  66

Event handling, Ajax, DOM manipulation and effects come immediately to mind. Especially when you factor in cross-browser issues.


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

Joined: Jan 10, 2002
Posts: 61095
    
  66

For example, here's an example I like to use. Following is some typical code to make an Ajax request, sending the value of a form field as a parameter, and shove the response text into a DOM element:


Here's the equivalent code using jQuery:


And this is a fair comparison. Both code examples work across multiple browsers that support Ajax, and both properly encode the request body.

The jQuery code actually performs some error-checking and event handling that the raw JavaScript example doesn't do.

Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3704
    
    5

Thanks Bear, that is actually the kind of comparison that's really useful.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Falling in love with jQuery?