Solved

Cannot get inner text of input tag

Posted on 2011-09-15
4
405 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Hi all! Recently there was EE question and the person wanted to have a multi-column textbox <div> selection, so as a first step to answer I provided a link but that was not complete with JavaScript selection, but had a good style sheet. So as a ques…
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
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…

785 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