是
$(this).attr('id')
与:
相同this.id
最佳答案
不,它们并不完全相同。
它们都会返回元素的 ID,但如果元素没有 ID,则 this.id
将返回空字符串,而 $(this).attr("id")
将返回未定义
。
关于jquery - this.id 与 $(this).attr ('id' ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5597317/