Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 440
  • Last Modified:

Cannot get inner text of input tag

The alert box appears, but is empty.  I want it to show the contents of the input tag with name="search".



 $('input[value="go"]').click(function ()
        {
            //$('input[class="searchbox"]').css("border", "3px solid yellow");
            alert($('input[class="searchbox"]').text());
            //document.location.href = "/search.aspx?search=" + $('input[class="searchbox"]').html;
        });

here is the markup:

<div class="utenn_search" id="utbk_searcAh">
          <label for="search">search: </label>
          <input type="text" name="search" class="searchbox" value="Search" onfocus="this.value=''" title="search">
      <input name="go" class="submit" type="button" value="go">
</div>
0
Tom Knowlton
Asked:
Tom Knowlton
  • 2
2 Solutions
 
haloexpertsexchangeCommented:
try getting the value instead of the text, if it is empty then nothing has been set for the text.
0
 
leakim971PluritechnicianCommented:
alert($('input[class="searchbox"]').val());
0
 
leakim971PluritechnicianCommented:
alert($('input.searchbox').val());

or :

alert($('.searchbox').val());
0
 
Tom KnowltonWeb developerAuthor Commented:
thx, that was it.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now