With jquery, is there a way to make val () return an empty string instead of 'undefined' when called with an empty list of elements?
For example, I have this code:
var x = $('#my-textbox-id').not('.watermark').val();
The idea is that I want to get the value of my text box, but I want an empty string if the watermark is currently displayed (I don't want the watermark value!).
The selector works, but I don't want 'undefined' - I want an empty string. ''
source
share