Get values from a HTML array with Jquery -


my goal values specific row in html array , put them forms, :

$("#tableid tr").click(function() {     var mh = $(this).closest("tr");     document.getelementbyid("catégorie").value= mh.find("td:first").text(); } 

this 1 above works : first value of row , appropriate form filled it. how can same other values of row ? tried several methods several key-words, i'm doing wrong... in advance.

use below code using each()

 mh.find("td").each(function(index){     // index return index of td    // $(this).text()  return text of each td    if(index == 0){      $("#catégorie").val($(this).text());    }  }); 

or can use :eq() selector text of td base on index

$("#catégorie").val(mh.find("td:eq(0)").text()); $("#othervalue").val(mh.find("td:eq(1)").text()); 

Comments