Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7435557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:05:38+00:00 2026-05-29T10:05:38+00:00

I was wondering if some jQuery expert would be so kind to convert the

  • 0

I was wondering if some jQuery expert would be so kind to convert the below script to jQuery. I am having trouble converting it myself and would much prefer to use a jQuery equivalent.

What I am trying to do is simply remove the default value of ‘Search’ from a keyword field onSubmit, as the user can leave the keyword field blank.

function clearValue() {
    var searchValue = document.getElementById("global-search").value;
    if (searchValue == "Search") {
        document.getElementById("global-search").value = "";
    }
}

Any help would be much appreciate.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T10:05:39+00:00Added an answer on May 29, 2026 at 10:05 am
    //wait for the DOM to be ready (basically make sure the form is available)
    $(function () {
    
        //bind a `submit` event handler to all `form` elements
        //you can specify an ID with `#some-id` or a class with `.some-class` if you want to only bind to a/some form(s)
        $('form').on('submit', function () {
    
            //cache the `#global-search` element
            var $search = $('#global-search');
    
            //see if the `#global-search` element's value is equal to 'Search', if so then set it to a blank string
            if ($search.val() == 'Search') {
                $search.val('');
            }
        });
    });
    

    Note that .on() is new in jQuery 1.7 and in this case is the same as .bind().

    Here is the documentation related to this answer:

    • .on(): http://api.jquery.com/on
    • .val(): http://api.jquery.com/val
    • document.ready: http://api.jquery.com/ready/
    • jQuery Selectors: http://api.jquery.com/category/selectors/
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm wondering what are some common misconceptions of jQuery? I've found there is a
I was wondering if someone could help with with some jquery code for doing
I would like to get some advice on structuring my javascript code and jquery
Wondering if anyone can assist.. I am adding some jquery to my site, but
I was wondering if eval (or some variant of jQuery's getScript) can be used
I was wondering if you could help me with some animation in jQuery. I
I'm seeing an issue regarding some jquery animation in chrome. I'm wondering if anyone
I am new to MVC3.0 and have to use jquery. I as wondering some
I am new to web development, learning ASP.NET. I used some JQuery script so
i was wondering if the following code would cause some problems like memory leak

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.