I'm currently facing an issue where I need to apply a class to an element when a certain data property changes. My approach involves using a watcher to monitor the value change and adding a class through JavaScript, as demonstrated in the code snippet below.
<div class="ad-video" >
watch: {
testAdActive() {
document.querySelector('.ad-video').classList.add('ad-resize');
}
}
Unfortunately, it seems that the above code is not functioning as expected, with the class 'ad-resize' failing to be added. Any suggestions on alternative approaches would be greatly appreciated.
Thank you, Jyoti