Try changing it to:
<input type="text" id="desc" name="txtTitle" onclick="fun.call(this)">
Better associate an event handler with jQuery since you are using it:
$(function() { $('#desc').click(fun); });
The reason your code does not work is because you are calling fun()from the event handler function created by the browser for your onclick attribute. Just by calling such a function, you do not provide the recipient object - nothing to thisbe, that is. If you call it with .call(), you can explicitly do it.
source
share