I have this simple ghost text implementation:
HTML code:
@mgiuca is entirely right about Javascript variables - the '$' that precedes them is just a naming convention that most use to identify jQuery objects. I add this because you say
because i tried storing jQuery object in non-jQuery variable
but this is wrong. $txtField
is a string that you are using to select an object. If you want to store the object itself you should do $txtField = $(#searchPanel form input.ghText)
and then use it thusly $txtField.val()
.
Having said that your code works fine for me unaltered. I've set up a demo which works on Chrome - is this a cut down version of you code?