Solved

Cannot get inner text of input tag

Posted on 2011-09-15
4
415 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:Tom Knowlton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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:Tom Knowlton
ID: 36544559
thx, that was it.
0

Featured Post

Understanding Linux Permissions

Linux for beginners: How to view the permissions associated with files and directories and also how you can change them.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…
Suggested Courses

636 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