This jQuery code removes the value of a input text type when the user clicks on the input. $(document).ready(function(){ $(function(){ $('input:text').each(function(){ var inputValue = $(this).val(); $(this).focus(function(){ $(this).val('') }); $(this).blur(function(){ if($(this).val() == ""){ $(this).val(inputValue); } }); }); }); });
Category Archives: JavaScript
getElementsByClassName function
Since there doesn’t exist something like a getElementByClassName function, I just tried the js prototype library which has a getElementsByClassName function. You can download it here. Include it in the head like this: <head> <script type="text/javascript" src="prototype.js"></script> </head> Then use it like this: var test = document.getElementsByClassName("test"); the variable test will be an array.
Posted in JavaScript Leave a comment