Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Banned
    Join Date
    Mar 2007
    Posts
    1,523
    Thanks
    116
    Thanked 0 Times in 0 Posts

    Question Show / Hide value of a search box?

    Hi, using the code below, I am trying to show / hide the value of my search box but it doesn't seem to work?! I am using Jquery 1.9 and I have the following code in my footer..
    Code:
    <script type="text/javascript">
       $("#searchbox").on({
    	    focus: function() {
            	if (this.value==='Search...') this.value = '';
        	},
       	 blur: function() {
           	 if (this.value==='') this.value = 'Search...';
       	 }
    	});
    </script>

    my page:
    http://aet.inpreview.net/

  • #2
    New Coder
    Join Date
    Jan 2013
    Posts
    10
    Thanks
    3
    Thanked 1 Time in 1 Post
    PHP Code:
       $("#searchbox").on({
            
    focus: function() {
                if (
    this.value==='Search...'){ this.value=''; };
            },
            
    blur: function() {
             if (
    this.value===''){ this.value 'Search...'; };
            }
        }); 

  • #3
    Banned
    Join Date
    Mar 2007
    Posts
    1,523
    Thanks
    116
    Thanked 0 Times in 0 Posts

    Question

    done that thanks, still not working, hmm maybe it's something to do with wordpress?!

  • #4
    New Coder
    Join Date
    Jan 2013
    Posts
    10
    Thanks
    3
    Thanked 1 Time in 1 Post
    What "doesn't work"? What error messages do you get?

    It works here: http://jsfiddle.net/sU2fT/

  • Users who have thanked Kyle123 for this post:

    jarv (01-22-2013)

  • #5
    Banned
    Join Date
    Mar 2007
    Posts
    1,523
    Thanks
    116
    Thanked 0 Times in 0 Posts
    Sorry, it does work, my browser was cached

    thanks
    Last edited by jarv; 01-22-2013 at 09:38 AM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •