-1

Here is my HTML code:

<div id="mySignin">
    <div class="modal-body">
        <form class="form-horizontal @loginGuid">
            <div class="captcha">
                <img class="imgCaptcha" title="@LocalizeHelper.GetLocalizeString("Click to change captcha code")" src="@Url.Action("CaptchaImage", "Account")" />
                <input type="text" class="inputCaptcha" />
            </div>
        </form>
    </div>
</div>

How can I select <input type="text" class="inputCaptcha" /> using JQuery?

John Slegers
  • 45,213
  • 22
  • 199
  • 169
Mohsen
  • 31
  • 1
  • 7
  • 4
    This is a very basic question. You should look through both http://learn.jquery.com and http://try.jquery.com before diving any further into jQuery. – James Donnelly May 09 '14 at 13:02
  • Selecting dom elements is a basic paradigm in CSS. You should check this out: http://www.w3schools.com/cssref/css_selectors.asp – Jefraim May 09 '14 at 13:07

5 Answers5

1

You can use . to target elements by class name:

$('.inputCaptcha')

I'd suggest you to go through jQuery official learning center to learn more about jQuery.

Felix
  • 37,892
  • 8
  • 43
  • 55
0

Your element has class attribute. You can use class selector to target it.

 var captchinp = $('.inputCaptcha');
Milind Anantwar
  • 81,290
  • 25
  • 94
  • 125
0

Just select it by its class

$('.inputCaptcha')

or if you want to only select inputs with the class:

$('input[type=text].inputCaptcha')
Robin Drexler
  • 4,307
  • 3
  • 25
  • 28
0

you may have some other elements rather that input elements with the class inputCaptcha, so target elements with more relevance by the selector give below.

Try,

$('input[type="text"].inputCaptcha')
Rajaprabhu Aravindasamy
  • 66,513
  • 17
  • 101
  • 130
0

You can use class selector like below

$('.inputCaptcha')

but if you have other html element with same class=inputCaptcha and you want to select only input then use below

$('input[class="inputCaptcha"]')

Please see JQuery Selector for more details

Bhushan Kawadkar
  • 28,279
  • 5
  • 35
  • 57