I am using an .on
click function to enable a setting. How would I modify this to say on click, toggle the (true)
value from false to true and back again on the next click?
$("#myBtn").on('click', function(){
panorama.setVisible(true);
});
you can achieve this by using a boolean
let isVisible = true;
$("#myBtn").on('click', function(){
panorama.setVisible(isVisible);
isVisible = !isVisible;
});
So everytime you click it, isVisible
will swap between true
and false
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.