javascript - How to get all text from all textboxes with class txt_Answer -


    <table id="tb_answers">     <tbody>    <td>     <input class="txt_answer" placeholder="enter answer">     </td>     <td>      <td colspan="4">     </tr>     </tbody>     <tr>     <td>     <input class="txt_answer" placeholder="enter answer">     </td>     <td>     <td>     </tr>     <tr>     <td>     <input class="txt_answer" placeholder="enter answer">     </td>     </tr>     </table> 

i got 3 inputs answers.how text/answer class txt_answer tried this

$('*[class="txt_answer"]').val() 

but returns me first value not of thaem

by iterating , creating array $.map :

var values = $.map($('input.txt_answer'), function(el) {return el.value;}); 

fiddle

you should validate html, it's not valid


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -