admin管理员组

文章数量:1399887

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/qwert.jpg" class="hi">
    <input type="text" class="multiple">
    <img src="www.xyz/qwerty.jpg" class="hi">
    <input type="text" class="multiple">
    <img src="www.xyz/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? 
 });

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./qwert.jpg" class="hi">
    <input type="text" class="multiple">
    <img src="www.xyz./qwerty.jpg" class="hi">
    <input type="text" class="multiple">
    <img src="www.xyz./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? 
 });
Share Improve this question edited Apr 14, 2015 at 7:32 Brijesh Bhatt 3,8303 gold badges20 silver badges34 bronze badges asked Apr 14, 2015 at 7:15 Nehil MistryNehil Mistry 1,1092 gold badges23 silver badges51 bronze badges 0
Add a ment  | 

3 Answers 3

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

Try this:

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

本文标签: javascriptMultiple class Get each valueStack Overflow