Vengat_93 Vengat_93 - 1 year ago 100
jQuery Question

how to create two event for html attribute

I would like to create two event by reusing the code of a method, this is my code, how could i able to create two event for single element using jQuery

blur : val (),
submit:val ()

function val() {
if ($('#country_ID').val() == '')
formval = false;

Thanks in Advance..

Answer Source

The simplest way to do it is as follows:

$('#country_ID').bind('blur submit', function (e) {
    // This is your combined function
    val(); //calling the required function
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download