首页 > 编程知识 正文

contribute和dedicate的区别,nature和property

时间:2023-05-06 09:00:04 阅读:168469 作者:668

比较属性

HTML元素的“选项|附加项”,格式:名称='值'。 只有字符串类型的值。 如果在编辑HTML时设置了元素的attribute值,则即使以后更改此值,attribute也会保留默认值。 建议将客户端添加到HTML元素的自定义属性称为属性。 属性

在JS DOM中,它是对象的成员(组件),因此可以在JS DOM对象中访问属性。值类型多样化:boolean、string、number等。 区分

位置不同。 attribute是HTML中元素的可选|附加模块。 属性位于JS DOM中。 对象的配置|成员。 值类型不同。 属性的值仅为字符串。 property是对象的成员,因此可以使类型多样化(bolean、string、number等)。 其他。 (结果)用于操作他们的jQuery方法也不同。 在jQuery1.6之前,经常使用attr ()。 在jQuery1.6中,区分属性和属性。 属性使用专用的prop ()。 其他使用attr ()。 booleanattributebooleanattribute及其规格的值

是一种特殊类型的属性。 例如selected。

如果selected未出现在元素的开始标记中,则表示元素的selected属性值为false。

但是,无论其值(空字符串)、其他字符串的值(false,)、(1,)、(hhh ) )如何,

当显示开始标记时,该值为true (或最小化格式,不仅仅是其他名称)。

其他还有checked、required、disabled、enabled等,

其存在所表示的含义实际上是布尔值,因此可以作为property (值的多态性)进行读写。 来定义自定义外观。

links js : attribute vs.property

What is a property? jsdomobjectshaveproperties.thesepropertiesarekindoflikeinstancevariablesfortheparticularelement.as such,apropertycanbedifed propertiescanbeaccessedusingjquery’spropmethod (asseenbelow ) andalsobyinteractingwiththeobjectinvanillajs.asyoollla alllla ailablethroughprop.otherpropertiesareavailabletoo,such as style,eventhoughwedidn’texplicitlysetthem.propertiescanalsoblsoblsobetoo Attributes are in the HTML itself,ratherthaninthedom.theyareverysimilartoproperties, utnotquiteasgood.whenapropertyisavailableit’srecommendedthatyouworkwithpropertiesrathanattributes.anattributeisonly sssonly noothertype.ifanelementhasadefaultvalue、 theattributeshowsthedefaultvalueevenifthevaluehaschanged.attributescanbeusefulwhenyouwanttosetacustomattribute,that is, whenthereisnopropertyassociated.but,to be fair,youcanalsousecustomproperties ' (althoughthismightbebadpractice )。

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。