js 獲取樣式值以及樣式屬性值

this.delayGetDomTimer = setTimeout(() => {
      for (let i = 0; i < myCollection.length; i++) {
        const str =
          myCollection &&
          myCollection[i] &&
          myCollection[i].getAttribute('style') // 獲取樣式值(包含所有屬性)
        // console.log('myCollection:', str, typeof str)

        if (
          typeof str === 'string' &&
          str.indexOf(`mso-char-indent-count: ${19}`) > -1
        ) {
          myCollection[i].style.textAlign = 'right'
        }
        console.log(window.getComputedStyle(myCollection[i], null).textIndent) // 獲取樣式屬性值
      }
    }, 300)

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章