Adding a change event on a hidden field

Adding a change event on a hidden field


Hi,
I would like to be able to trigger a function when the value of a
hidden field is changed through val() - and I want this event to be
attached to the field itself, not to the val() action.
As events are only users' triggered a hidden field doesn't trigger
onchange natively. I have seen a lot of implementations using various
plug-ins for mutation events, but was not very happy about them -
they're heavy and I got some errors.
Therefore I have added a line at the very end of the val() function:
            if(o.nodeName(this,"select")){
...
            }
            else{
                this.value=K;
// Here's my line:
                if(this.type=='hidden'){$(this).change()}
            }
        }
    }
)}
That works fine in IE6, FF and Chrome - haven't tested on other
browser.
Would it be useful to add this?
Thanks!
Here's an example:
<html>
<head>
<script type="text/javascript" src="_shared/js/jquery-1.3.2.min.js"></
script>
<script type="text/javascript">
$(function(){
    $("#hiddenField").change(function(e){
        alert($(this).val());
    });
    setTimeout('$("#hiddenField").val("wooloo");',2000);
});
</script>
</head>
<body>
<input type="hidden" id="hiddenField" value="BaBna" /><br />
</body>
</html>