Reputation: 1109
How can I get value of textbox appended with image tag. There is list of images with class="hi" and textbox with class multiple.
<div id="images">
<img src="www.xyz.com/qwert.jpg" class="hi">
<input type="text" class="multiple">
<img src="www.xyz.com/qwerty.jpg" class="hi">
<input type="text" class="multiple">
<img src="www.xyz.com/qwertww.jpg" class="hi">
<input type="text" class="multiple">
</div>
How can I get src and value of textbox ?
Script I tried:
var values = "";
$(".hi, .multiple").each(function () {
imageURI = $(this).attr('src'); // I am getting imageURI
???? //How can I get texbox value?
});
Upvotes: 2
Views: 4691
Reputation: 32354
$(".hi").each(function () {
var imageURI = $(this).attr('src');
var textBoxVal = $(this).next('input').val();
});
Upvotes: 2
Reputation: 647
Try this:
var values = "";
$(".hi, .multiple").each(function () {
imageURI = $(this).attr('src'); // I am getting imageURI
textBoxVal = $(this).val();
});)
Upvotes: 0
Reputation: 3830
$(".hi").each(function () {
var imageURI = $(this).attr('src');
var textBoxVal = $(this).next().val();
});
Upvotes: 5