i'm trying to write unobtrusive default/placeholder text in input (actually, relatively placed label
over input
, which hides on onFocus
, and stays hidden if input isn't empty on onBlur
), but I don't want to use jQuery, because this is the only javascript used on page - therefore using jQuery seems a bit over the top.
Please, how can I do this without jQuery?
Thank you.
EDIT: I know the idea (getElementByID
), but I'm more looking into how to add it to document - preferably something you have used before. Thank you.
EDIT: Thank you all, I finally went with jQuery, seeing answers :] (my example is here: http://jsbin.com/ehega/3 - it's concept, I'll probably add more eye candy. As an answer I Robert Koritnik - because of valid points... and styling ;])
Here's how I do:
Online Working Example
http://jsbin.com/ehivo3 (source code)
HTML
jQuery
And that's all! No invalid or extra attributes, valid markup and all handled in your jQuery file. :)