Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Html/Form events vs JQuery events

Posted on 2012-03-11
3
Medium Priority
?
485 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 13

Accepted Solution

by:
Hugh McCurdy earned 2000 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
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 …
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…

721 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