Reputation: 588
I have want to get values from my form in jquery
Here is my html code:
<table class="table table-hover table-striped table-condensed">
<tbody><tr id="properties_view">
<td><h4>Location</h4></td>
<td><h4>Substage</h4></td>
<td><h4>Crypted</h4></td>
<td><h4>Key</h4></td>
<td><h4>Value</h4></td>
<td><h4>Comments</h4></td>
<td><h4>Delete</h4></td>
</tr>
<tr><td class="value">ANY</td><td class="value">MAIN </td><td class="value">false</td><td class="value">unitesbudg_roic_assetcenter.V01.aaf.filename</td><td class="value">unitesbudg_roic_assetcenter.txt</td><td class="value">undefined</td><td><a href="#" class="delete_line" id="unitesbudg_roic_assetcenter.V01.aaf.filename"><img src="img/delete.png"></a></td></tr>
<tr><td class="value">ANY</td><td class="value">MAIN </td><td class="value">false</td><td class="value">personnes_roic_assetcenter.V01.aaf.filename</td><td class="value">personnes_roic_assetcenter.txt</td><td class="value">undefined</td><td><a href="#" class="delete_line" id="personnes_roic_assetcenter.V01.aaf.filename"><img src="img/delete.png"></a></td></tr>
<tr><td class="value">ANY</td><td class="value">MAIN </td><td class="value">false</td><td class="value">common.aaf.folder</td><td class="value">ROI/out/</td><td class="value">undefined</td><td><a href="#" class="delete_line" id="common.aaf.folder"><img src="img/delete.png"></a></td></tr>
</tbody></table>
I tried this js but it doesnt work
Here is my js
code. When I click the button <a href="#" class="commit_properties" id=""><button class="btn btn-info" type="button">Commit</button></a>
I try to debug in the Chrome Console.
$("#page_body").on('click', 'a.commit_properties', function(e) {
var debug;
debug = $(this).$('table').text();
console.debug(debug);
});
Upvotes: 1
Views: 70
Reputation: 12209
First off you don't need to wrap your button in an anchor tag. In fact I don't see any reason why you'd want to. To loop through the values in your table, use JQuery's each
function:
$("#page_body").on('click', 'button', function (e) {
$('.value').each(function(i,e){
console.log($(e).text());
});
});
See jsFiddle.
Upvotes: 1