Why alert AnchorElement () alerts the href attribute?

前端 未结 3 1855
眼角桃花
眼角桃花 2021-01-21 17:24
A link

$.each($(\'a\'), function(index,value){
    alert (value)
});

It will alert : url. Why this happen

3条回答
  •  春和景丽
    2021-01-21 18:08

    value is HTMLAnchorElement object, HTMLAnchorElement.toString() method return its url attribute.

    alert will use .toString() when display an object.

提交回复
热议问题