0

I generate markup dynamically and id for inputs elements:

<div class="wrap_input fancy_form" style="margin-bottom: 10px; margin-top: 28px;">
        @foreach(var seatType in Model.UsingSeatType)
        {
            int i = 1;
            <p class="inp_label" style="width: 50px;">@(seatType.Value):</p>
            <i>&nbsp;</i>
            <input type="text" id="type@(i)" value="" data-price=""  style="width: 50px;" />
            i++;
        }
    </div>

How can I find all this inputs(type1, type2, type3 and so on)?

 $("#type?").spinner(); 

Thanks.

BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
user1260827
  • 1,498
  • 6
  • 31
  • 53

3 Answers3

2

Just try this code

$('.wrap_input.fancy_form input[type=text][id^=type]').spinner();
The System Restart
  • 2,873
  • 19
  • 28
2

How about you make the following changes:

Add a class to your input:

<input class="seat_type" type="text" id="type@(i)" value="" data-price=""  style="width: 50px;" />

Use jQuery selector on the class

$(".seat_type").spinner();

I suggest these changes because it would be easier to read for most people.

filype
  • 8,034
  • 10
  • 40
  • 66
0

You can try this:

$('input[id^="type"]').spinner();

More info here.

tobias86
  • 4,979
  • 1
  • 21
  • 30