Why alert AnchorElement () alerts the href attribute?

前端 未结 3 1877
眼角桃花
眼角桃花 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 17:54

    the reason you get url is because .each takes a container(array||object) and then uses your callback function to process the container. it will take an array's elements, or an object's properties, and iterate over them. since the property of your selector object is "href", you will get the url value.

提交回复
热议问题