Skip to Content
Introducing .NET 4.0: with Visual Studio 2010
book

Introducing .NET 4.0: with Visual Studio 2010

by Alex Mackey
February 2010
Beginner content levelBeginner
400 pages
11h 13m
English
Apress
Content preview from Introducing .NET 4.0: with Visual Studio 2010

12.6. Adding Functions

A common problem many designers and developers encounter is the separation of design from code. Many developers (in fact, I got you to do this in the very first example of this chapter), if asked to call a JavaScript function when a button is clicked, will write something such as this:

<input id="cmdTest" type="button" value="Hello jQuery"
       onclick="javascript:hellojQuery();" />

However, this is not the best way because it is very vulnerable to polo-neck wearing, snowboarding designer corruption, and it isn't standards compliant.

jQuery offers a neat solution with the .bind() method. The following code binds the hellojQuery() function to the click of the cmdTest button:

$("#cmdTest").bind('click', hellojQuery());''
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

ASP.NET 3.5 For Dummies®

ASP.NET 3.5 For Dummies®

Ken Cox
ASP.NET 4 Unleashed

ASP.NET 4 Unleashed

Stephen Walther, Kevin Hoffman, Nate Dudek

Publisher Resources

ISBN: 9781430224556Purchase book