I have the following code:
<li class="order_line">
<div class="rating">
<input type="textbox" value="10" maxlength="3" class="store_rating" name="item_rating">
</div>
<div class="cost">
<input type="textbox" readonly="readonly" value="469" maxlength="3" class="store_cost" name="item_rating">
</div>
</li>
The closest I get is using this code:
var cost = $(this).parent().next().html();
An alert(cost) will ouput the entire <input... string.
But I’m not able to get the value.
I’ve found several similar problems (that’s how I almost got the solution), but I’m not able to complete the last steps.
What am I missing here?
var cost = $(this).parent().next().find("input").val();You need to search within the parent
divto find theinput, and then get the value usingval()Or if you only have two, like in the example above, you could use something like:
$("input").not(this).val()