开发者

Why console shows different things when I use querySelector()?

开发者 https://www.devze.com 2022-12-07 20:11 出处:网络
when I use document.querySelector(), At first, I can see html tag in console like this. // this is JS code

when I use document.querySelector(), At first, I can see html tag in console like this.

// this is JS code
allProducts.forEach((product) => {
**const productList = document.querySelector('.product-list');**
console.log(productList);
});
// console.log
<d开发者_JS百科iv class="product-list">
      <!-- <div class="product">
        <img src="imgs/imgs/blue_s.png">
        <p>female, small size</p>
      </div> -->
    </div>

but after page refresh, console shows this.

//console.log
div.product-list (This is object.)
 accessKey:""
 align: ""
 ariaAtomic: null
 ariaAutoComplete: null
 ariaBrailleLabel: null
 ariaBrailleRoleDescription: null
 ...

I read MDN .querySelector() page(https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector). It says .quesySelector()'s return value type is 'Element'. But still, I don't know which one is 'Element' type and why I had to see html tags like first one before page refresh.

+) I am using Chrome browser.

0

精彩评论

暂无评论...
验证码 换一张
取 消