jquery - How to get checkbox value and the value of the selected option of dropdown menu next to it -
i have table , first 2 columns check box , drop down menu. want value of check box , of selected item next , put in array. in essence want :
[object { name="blabla", value="bla"} , object {name='s1' value='3'}]
.
where first object check box , second 1 drop down menu. played around bit .closest
can't seem able chain them together.
here fiddle: http://jsfiddle.net/vulkoingim/kub67/
try this:
$(document).ready(function () { var arr = []; $('#test').click(function () { $("#t tr").each(function () { $this = $(this) var $checkbox = $this.find("input:checkbox") var $select = $this.find("select[id^=s]"); arr.push({ name: $checkbox.attr('name'), value: $checkbox.val() }); arr.push({ name: $select.attr('id'), value: $select.val() }); }); console.log(arr); }); });
Comments
Post a Comment