J'ai des problèmes avec ce code: je ne peux pas obtenir la valeur de textbox il:Comment obtenir la valeur de la zone de texte à l'intérieur de la table en utilisant jquery?
voici mes codes:
$(document).ready(function() {
$('#btnsave').click(function() {
//saveData();
// for looping the tr id:
$("tr#mytr", "#mytable").each(function() {
// how to get value of pos_x in every tr??
});
})
});
et voici le code html
<table style="width:100%" id="mytable">
<tr id="mytr">
<td>
X position:
</td>
<td>
<input id="xPositionField" name="pos_x" style="width:100%"/>
<input id="yPositionField" name="pos_y" style="width:100%"/>
</td>
</tr>
<tr id="mytr">
<td>
Y position:
</td>
<td>
<input id="xPositionField" name="pos_x" style="width:100%"/>
<input id="yPositionField" name="pos_y" style="width:100%"/>
</td>
</tr>
<tr id="mytr">
<td>
Width:
</td>
<td>
<input id="xPositionField" name="pos_x" style="width:100%"/>
<input id="yPositionField" name="pos_y" style="width:100%"/>
</td>
</tr>
<tr id="mytr">
<td>
Height:
</td>
<td>
<input id="xPositionField" name="pos_x" style="width:100%"/>
<input id="yPositionField" name="pos_y" style="width:100%"/>
</td>
</tr>
<tr id="mytr">
<td>
Last save date:
</td>
<td>
<input id="xPositionField" name="pos_x" style="width:100%"/>
<input id="yPositionField" name="pos_y" style="width:100%"/>
</td>
</tr>
<tr>
<td colspan="2">
<input type="button" name="btnsave" value="Save" id="btnsave" >
</td>
</tr>
</table>
dans ce code, j'utilise même id de tr et certains id de chaque zone de texte ...
Vos attributs d'ID doivent être uniques, vous ne pouvez pas utiliser le même ID sur plusieurs éléments. Utilisez l'attribut class à la place. –