Sometimes there are cases when you need to do something when $.val() and $.val(value) from jQuery is called, but then you still want the default behavior to be kept. Here is an example of how you could do that:
I for example have used it for a jQuery widget, I wanted to override the default behavior of the val() function when this is performed on the element for which a widget was used. So what I have done is I have added a custom attribute to the element for which I am using the widget and then in the val() I am checking the presence of that attribute - just like below:
This is all.