Search code examples
javascripthtmlfunctiononkeyupreferenceerror

JS referenceError: change is not defined


I have 4 input boxes that call a function when the key is lifted using the onkeyup event. For some reason, I am getting an error saying that "change" (the function's name) is not defined. I am definitely defining the function correctly, so I have no idea what's causing this.

The demo will explain much better than me:
(source: snag.gy)

OK, got it. I was getting that error, but the cause what not what I had suspected. http://jsfiddle.net/qWcZ6/2/


Solution

  • Not sure what exactly you're trying to do, but the following works (fiddle):

    function change(variable) {
        var value = $(variable).val();
        alert(value);
        $(variable).html(value);
    }