Warning: Cannot modify header information - headers already sent by (output started at /home/dealkhus/cosmoread.com/wp-includes/formatting.php:5079) in /home/dealkhus/cosmoread.com/wp-content/themes/cosmoread/header.php on line 18

Warning: Cannot modify header information - headers already sent by (output started at /home/dealkhus/cosmoread.com/wp-includes/formatting.php:5079) in /home/dealkhus/cosmoread.com/wp-content/themes/cosmoread/header.php on line 19

Warning: Cannot modify header information - headers already sent by (output started at /home/dealkhus/cosmoread.com/wp-includes/formatting.php:5079) in /home/dealkhus/cosmoread.com/wp-content/themes/cosmoread/header.php on line 20

Warning: Cannot modify header information - headers already sent by (output started at /home/dealkhus/cosmoread.com/wp-includes/formatting.php:5079) in /home/dealkhus/cosmoread.com/wp-content/themes/cosmoread/header.php on line 21
Home » Shopping » Clear textbox using simple JavaScript
How to achieve text-box clear using simple JavaScript not using Jquery

Clear textbox using simple JavaScript

Today I tried to clear my text box using a method, when I will click on my text box the inistail value will be clear and when I revert the same value will be display. As I have a website I can easily do this using J query so again I have to write-down some script. But After putting JQuery I find some of my UI get spoiled so I switch to simple JavaScript with easier method to clear a text box. First I wrote JQuery see below:

 

 

But by using above script my textbox works well but after browsing my website I find some UI get disturb so once again I switch to simple JavaScript and I find a simple method to do so.

I tried with HTML Textbox and injected an inline code

This so simple core JavaScript with no dependencies, I hope you like this which do same as above using Jquery

onblur="if (this.value == '') {this.value = 'username';}" onfocus="if (this.value == 'username') {this.value = '';}"