Switch state acquisition" on the official website doesn't seem to work even if it's copied. Has the specification changed?
html
<ons-switchid="switch-1">/ons-switch>
JS
var switch= document.getElementById('switch-1');
ons.notification.alert('Value is' + switch.checked);
The HTML(?) listed as an example on the Switch State Retrieval page on the official site (https://ja.onsen.io/v2/api/js/ons-switch.html) does not have an element with the ID switch-1 (or no element with the ID specified).(as of March 16, 2020 at 10:55)
Therefore, switch= document.getElementById('switch-1'); gets nothing and
When I tried to display switch.checked, was there an error?
© 2024 OneMinuteCode. All rights reserved.