dunno if somebody answered this already, but you should remove the .change() call at the end of your chain, because it immediately triggers your change function, and thus firing your test alert..

dennis.

cnxmax wrote:

I'm trying something pretty basic in JQuery (I think).

I want to run a function that will make it so that every Input on the
page will run a function (in this case, alert) whenever the "change"
event happens for that element.

It does work, but for some reason the "test" alert also fires right
when I first run sasBindFormEvents(). Why is this? I only want the
"test" alert when something is typed and then the focus is removed
from the input.

CODE:
================================================

function sasBindFormEvents() {
    $('input').change(function () {
          alert('test');
        })
        .change();
}

================================================


Reply via email to