Solved

Html/Form events vs JQuery events

Posted on 2012-03-11
3
478 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
OverviewThis article demonstrates a simple search form using AJAX. The purpose of the article is to demonstrate how to use the same code to render a page and javascript (JQuery) and AJAX to make subsequent calls to refine the results. The princip…
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…

803 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