对于HTML元素本身就带有的固有属性,在处理时,使用prop方法。
对于HTML元素我们自己自定义的DOM属性,在处理时,使用attr方法。
例如:
是否可见
是否可见
1,
$("#chk1").prop("checked") == false
$("#chk2").prop("checked") == true
2,
$("#chk1").attr("checked") == undefined
$("#chk2").attr("checked") == "checked"