getAttribute()和setAttribute()还是有点搞不清
getAttribute() and setAttribute() are still a bit confusing - PHP Chinese website Q&A - getAttribute() and setAttribute() are still a bit confusing - PHP Chinese website Q&A
Take a look around and learn.
getAttribute(name)
是读,从已有的属性值中读取
setAttribute(name,value)
是写,有两个参数,先根据第一个参数查找当前元素是否有‘name’属性,如果没有就添加一个‘name’属性,然后再将第二个参数值赋给名为第一个参数值‘name’的属性
getAttribute() and setAttribute() are still a bit confusing - PHP Chinese website Q&A - getAttribute() and setAttribute() are still a bit confusing - PHP Chinese website Q&A
Take a look around and learn.
是读,从已有的属性值中读取
是写,有两个参数,先根据第一个参数查找当前元素是否有‘name’属性,如果没有就添加一个‘name’属性,然后再将第二个参数值赋给名为第一个参数值‘name’的属性