javascript - Update placeholder text with new text onClick/onFocus -


here 1 had come , solution baffled me , no search here @ revealed anything.

standard input field:

<input type="input" name="fname" placeholder="your first name"> 

but let update placeholder text when clicks on field or when field onfocus via pressing tab key.

so become:

<input type="input" name="fname" placeholder="your first name goes here"> 

just basic example of do, adding "goes here" placeholder text.

doable? possible modify placeholder? unknown me.

if , possible via pure js or via jquery, entertained in seeing how.

this should (edit:added blur reset):

$('input[name=fname]').on("click focus",function(){     $(this).attr("placeholder","your first name goes here"); }).on("blur",function(){     $(this).attr("placeholder","your first name"); }); 

updated fiddle: http://jsfiddle.net/6tb8v/1/


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -