Nehil Mistry
Nehil Mistry

Reputation: 1109

Multiple class Get each value

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

Answers (3)

madalinivascu
madalinivascu

Reputation: 32354

$(".hi").each(function () {                  
    var imageURI = $(this).attr('src'); 
    var textBoxVal = $(this).next('input').val(); 
 });

Upvotes: 2

user4341206
user4341206

Reputation: 647

Try this:

var values = "";                    
$(".hi, .multiple").each(function () {                  
    imageURI = $(this).attr('src'); // I am getting imageURI
    textBoxVal =  $(this).val();
 });)

Upvotes: 0

Brijesh Bhatt
Brijesh Bhatt

Reputation: 3830

$(".hi").each(function () {                  
    var imageURI = $(this).attr('src'); 
    var textBoxVal = $(this).next().val(); 
 });

Upvotes: 5

Related Questions