this.id vs. $(this).attr('id')

前端 未结 3 689
北海茫月
北海茫月 2020-12-09 07:27

Is

$(this).attr(\'id\') 

the same as:

this.id
3条回答
  •  渐次进展
    2020-12-09 08:25

    Same result, but this.id is much faster as it doesn't require all the jQuery stuff around it. You will also get different results if that item doesn't have an id.

提交回复
热议问题