JQuery - How to put row's value into a list
I have a table with a checkbox input on each row. I would like to put all
the value of this input (ordered) into a var list when the href="#"
class="up" or the href="#" class="down" is clicked (moving a row up or
down).
In summury, I want to know how call the dom element "value" of the
"checkbox input" in a whole table.
table:
<table>
//first row
<tr>
<td><a href="/ezmapping/layer/edit/1">ra_general.shp,
burton449</a></td>
<td><label for="id_layers_0"><input checked="checked"
type="checkbox" id="id_layers_0" value="1"
name="layers"/></label></td>
<td><a href="/ezmapping/map/super/LayerStyle/1">Style</a></td>
<td>
<a href="#" class="up"><img
src="/static/main/img/arrow_up.png"></a>
<a href="#" class="down"><img
src="/static/main/img/arrow_down.png"></a>
</td>
</tr>
.
.
.
</table>
jquery (to move row up and down)
$(document).ready(function(){
$(".up,.down").click(function(){
var row = $(this).parents("tr:first");
if ($(this).is(".up")) {
row.insertBefore(row.prev());
} else {
row.insertAfter(row.next());
}
});
});
No comments:
Post a Comment