I am trying to use a function .isChecked()
from the OnsenUI framework on a name
.
My HTML is dynamic, so the number always changes. It's like:
<input type="checkbox" class="switch__input switch--list-item__input
ng-dirty ng-valid-parse ng-not-empty" ng-model="model" name="menu_switch_35399">
If I run it like:
console.log(menu_switch_35399.isChecked());
it WORKS FINE and returns true
or false
correctly. But when I try to access it dynamically, it doesn't. What am I doing wrong?
I tried:
var test = $('[name=menu_switch_' + id + ']');
// console.log returns menu_switch_35399
And then running
test.isChecked()
but that doesn't work. I also tried:
$('[name=menu_switch_' + id + ']').isChecked()
And that also doesn't work.
The error is always
Uncaught TypeError: test.isChecked is not a function
How can I access this dynamic variable?