Reputation: 1520
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> </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.
Upvotes: 0
Views: 1583
Reputation: 8380
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.
Upvotes: 2
Reputation: 5029
You can try this:
$('input[id^="type"]').spinner();
More info here.
Upvotes: 0
Reputation: 2881
Just try this code
$('.wrap_input.fancy_form input[type=text][id^=type]').spinner();
Upvotes: 2