Answers for "js get element by tag and attribute"

2

js get element by attribute

//find first element with "someAttr" attribute
document.querySelector('[someAttr]')
Posted by: Guest on November-13-2020
1

javascript document get by attribute

priceChange(price, prefix, key, id) {
            if (prefix === '+' && parseInt(price) > 0) {
                this.price_print = (parseInt(this.originalPrice) + parseInt(price)).toString().replace(/\B(?=(\d{3})+(?!\d))/g, " ");
            } else if (price !== null) {
                this.price_print = parseInt(this.originalPrice).toString().replace(/\B(?=(\d{3})+(?!\d))/g, " ");
            }
            document.querySelectorAll('[id_attr="attr' + key + '"]').forEach(function (el) {
                el.classList.remove('product__storage__item-active');
            });
            document.getElementById('value_option' + id).classList.add('product__storage__item-active');
        }
Posted by: Guest on April-18-2022

Code answers related to "js get element by tag and attribute"

Code answers related to "Javascript"

Browse Popular Code Answers by Language