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
  • 665,005
  • 155
  • 1,345
  • 1,328
user1260827
  • 1,438
  • 6
  • 31
  • 53

3 Answers3

2

Just try this code

$('.wrap_input.fancy_form input[type=text][id^=type]').spinner();
The System Restart
  • 2,893
  • 18
  • 27
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
  • 7,521
  • 9
  • 37
  • 63
0

You can try this:

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

More info here.

tobias86
  • 4,869
  • 1
  • 20
  • 30