【发布时间】:2021-01-06 21:16:01
【问题描述】:
我已使用以下代码将类添加到 Wordpress 网站上的 svg 图像。
window.addEventListener('load', function () {
const svg = document.querySelector('svg')
if (svg) {
const items = document.querySelectorAll(
'.woocommerce-grouped-product-list-item'
)
if (items) {
items.forEach((item) => {
item.addEventListener('mouseenter', (e) => {
item.classList.add('tab-brackground--active')
const text = e.target.children[0].innerText
jQuery(`[data-section="${text.toLowerCase()}"]`).addClass(
'svg--active'
)
})
})
}
}
})
item.classList.add('tab-brackground--active')
适用于我的移动版和桌面版,而
jQuery(`[data-section="${text.toLowerCase()}"]`).addClass('svg--active')
仅适用于我的桌面版本。
您可以通过此链接自行查看 - https://ticketblaster.com.au/product/keith-urban-melbourne-friday-10th-december-2021/
我能做些什么来解决这个问题?
【问题讨论】:
标签: javascript html jquery css wordpress