calling the jq function like you would do a js function from a form element

i am trying to validate a form using jquery (not use the validate plugin)...what i wanted to know was is there a way to call the same function without it being attached to a particular node...

like in js

<input id="xyz" ....onblur=js:function()>

<input id="abc" ....onblur=js:function()>

where as in jq

$(#xyz).blur(); 
$(#abc).blur(); 

not the exact syntax but you do get it...

thanks andy

Answers


$(function() {
  $(":input").blur(function() { 
    // executes this function every time the blur event
    // fires on any input element
  });
}

"input element" being input, textarea, select and button elements.

If you just want it to be executed when the blur event fires for regular inputs, lose the colon. Hope I got what you wanted to achieve.


Need Your Help

Using Facebook scores API in an Android App?

android facebook api

I am integrating the scores API for facebook in an Android game. I had the exact same problem as this question: Facebook Graph API Explorer won&#39;t POST scores. The fix was to set my app as Web i...

xExtend Values not updating

javascript d3.js

I am following the same code from this Gist

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.