Thursday 15 January 2015

jquery - Get id values from child inputs and push it to an array in Javascript on change -


I have a value [111, 123, 678 and so on ....] basically trying to get value If I click on the parents to check values ​​or input of children and output as an array, then the same checkbox is automatically selected: I have a good sense of JS, but with it still I'm struggling. I have a jsfiddle and looks like JS:

  $ (document) .ready (function () {$ ('# sidebar'). Append (dropdown_theater (events. ('' Change '', function () {var checkbox = $ (this) .Parent (next) ('ul';) (address ('input [type =' checkbox "] '); console.log ( Checkbox); [10101, 19199, 191 1, 119 9] If ($ (this) [0]. Checked == true) {checkboxes.each (function () {$ ( This) .prop ('checked', true) .attr ('checked', 'checked');}}} other {checkboxes.each (function () {$ (this) .prop ('check', incorrect). RemoveAttr ('check'); //console.log(this);}}}}}}}}} checkbox group ();  

I suppressed Bella.

I am not sure that you are the one who is after you. The value is available on E. Warning in the incident.

 < Code> var arr = []; function checkbox group () {$ ('# sidebarNav input [type =' checkbox "] '). (' Change ', function) {arr = []; var checkbox = $ (this ). Parent (). Next ('' ul '). ('Input [type =' checkbox "] '); //console.log (checkbox); [10101, 19199, 1919, 119191] If ($ (this) [0]. Checked == true) {checkboxes.each (function () {arr.push ( $ (This) .attr ("id"); $ (this) .prop ('checked', true) .attr ('checked', 'check');}); Other {checkbox.each (function () {$ (this) .prop ('checked', wrong) .removeAttr ('check'); //console.log(this);});}; Warning (arr);}); } Checkbox group ()  

No comments:

Post a Comment