Reputation: 19425
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?
Upvotes: 1
Views: 404
Reputation: 16961
var cost = $(this).parent().next().find("input").val();
You need to search within the parent div
to find the input
, and then get the value using val()
Or if you only have two, like in the example above, you could use something like:
$("input").not(this).val()
Upvotes: 3
Reputation: 47988
.parent()
gets you to a <div>
element, and .next()
gets you to the next <div>
. You want the child of that <div>
which is an <input>
.
Upvotes: 0