Solved

Cannot get inner text of input tag

Posted on 2011-09-15
4
397 Views
Last Modified: 2012-05-12
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
Comment
Question by:knowlton
  • 2
4 Comments
 
LVL 13

Accepted Solution

by:
haloexpertsexchange earned 475 total points
ID: 36543565
try getting the value instead of the text, if it is empty then nothing has been set for the text.
0
 
LVL 82

Assisted Solution

by:leakim971
leakim971 earned 25 total points
ID: 36543634
alert($('input[class="searchbox"]').val());
0
 
LVL 82

Expert Comment

by:leakim971
ID: 36543655
alert($('input.searchbox').val());

or :

alert($('.searchbox').val());
0
 
LVL 5

Author Closing Comment

by:knowlton
ID: 36544559
thx, that was it.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

by Julian Matz As of jQuery (http://jquery.com/) 1.4 the .live() method (http://api.jquery.com/live/) supports custom events as well as some standard JavaScript events that it previously didn't support. Among these is the submit event. Unlike …
Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now