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 Falling in love 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 "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: 3652

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

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


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

Joined: Jan 10, 2002
Posts: 56204
    
  13

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: 3652

Thanks Bear, that is actually the kind of comparison that's really useful.
 
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: Falling in love with jQuery?
 
Similar Threads
Jquery or Prototype
jquery small library
problem setting form Action name Dynamically on button click
jquery
Whats On India Error