Solved

Html/Form events vs JQuery events

Posted on 2012-03-11
3
477 Views
Last Modified: 2012-03-12
Hi Everyone,
This might have been asked before, but I can't find a good explanation anywhere.  Which technique would be better to use; attaching an event handler to an element of a html form, such as onBlur="Handler" with its own Javascript function, or applying the handler in the $(document).ready section of  the initial Javascript section?  I'd eventually like to have it interface with php on the server side, so I know I'll have to do some Ajax on it.  Both methods look like they would give pretty much the same result, but I've seen articles online and in books that use one or the other.
Thanks
0
Comment
Question by:William-B
  • 2
3 Comments
 
LVL 13

Accepted Solution

by:
Hugh McCurdy earned 500 total points
ID: 37708243
One method is not clearly better than the other.  They both end up using JavaScript (as I expect you already know).

I think the main distinction then is program maintainability.  You should choose the approach that is easier to follow.

IMHO, I think that means JQuery because I can automatically tell the maintenance engineer which areas of the page use JavaScript because I would (normally) identify areas by id and a good editor could then find id='foo' or whatever.  So, I'd choose JQuery simply because it's more obvious.
0
 

Author Comment

by:William-B
ID: 37708389
Thanks for your response.  Looking at it now I can definitely see how JQuery could make things a lot more manageable and clear for anyone else working on it.  Thanks again for your input.
0
 
LVL 13

Expert Comment

by:Hugh McCurdy
ID: 37709326
Thanks for the points.  Program maintainability is a very important issue.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Sending E-mail ASP.Net 3 55
Download a website to hdd 2 47
JavaScript: Issue with onClick 5 34
How to turn a javascript bookmark into a hyperlink online 9 28
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

947 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now