Jquery属性还是属性?
我有一些来自代码隐藏的自定义属性 我使用Jquery属性还是属性?,jquery,asp.net,vb.net,Jquery,Asp.net,Vb.net,我有一些来自代码隐藏的自定义属性 我使用 sender.Attributes.Add("TextLinkNo", sender.TextLinkNo) sender.Attributes.Add("TextHeader", sender.TextHeader) sender.Attributes.Add("TextDisplay", sender.TextDisplay) sender.Attributes.Add("FSize", sender
sender.Attributes.Add("TextLinkNo", sender.TextLinkNo)
sender.Attributes.Add("TextHeader", sender.TextHeader)
sender.Attributes.Add("TextDisplay", sender.TextDisplay)
sender.Attributes.Add("FSize", sender.FSize)
sender.Attributes.Add("iRotation", sender.iRotation)
sender.Attributes.Add("PrintStatus", sender.PrintStatus)
sender.Attributes.Add("Parameter", sender.Parameter)
sender.Attributes.Add("SupportDEC", sender.SupportDEC)
html代码
<span id="ctl00_ContentPlaceHolder1_LabelAttributes1_TabContainer1_TabPanel1_08"
itextstyle="0" asign="0" supportdec="0" linetp="0" textlinkno="0" parameter="0"
supportfontsize="False" class="draglabel ui-draggable ui-resizable" printstatus="7"
spaceadjust="0" irotation="0" actc5="False" index="8" fieldformat="C1" ifontstyle="0"
stringstatus="0" fsize="-1" ialign="0" textdisplay="Commodity Name" textheader="False"
istartline="0" style="position: absolute; border-style: solid; border-width: 1px; left: 9px; top: 205px; width: 476px; height: 174px; background-color: rgb(255, 192, 203);" top="8" left="19">
Commodity Name
<div class="ui-resizable-handle ui-resizable-e" style="z-index: 90;"></div><div class="ui-resizable-handle ui-resizable-s" style="z-index: 90;"></div><div class="ui-resizable-handle ui-resizable-se ui-icon ui-icon-gripsmall-diagonal-se" style="z-index: 90;"></div></span>
但不是
$(this).prop("supportdec");
$(this).prop("data-supportdec");
i tot prop受支持attr支持的内容+附加内容?已经有很多问题询问了
.attr()
和.prop()
之间的区别
我建议大家通读这篇文章
差异也记录在.prop()
函数的jQuery
api中,该函数是
下面是从上面提到的jQuery站点获取的
属性与属性
属性和属性之间的差异在应用程序中可能很重要
具体情况。在jQuery1.6之前,有时使用.attr()方法
检索某些属性时考虑了属性值,
这可能会导致不一致的行为。从jQuery1.6开始,.prop()
方法提供了一种显式检索属性值的方法,而
.attr()检索属性
例如,应检索selectedIndex、tagName、nodeName、nodeType、ownerDocument、defaultChecked和defaultSelected
并使用.prop()方法进行设置。在jQuery之前
1.6中,这些属性可以使用.attr()方法检索,但这不在attr的范围内。这些没有相应的
属性和仅是属性
根据W3C表单规范,checked属性是
布尔属性,这意味着如果
即使(例如)属性
没有值或设置为空字符串值,甚至设置为“false”。这是
所有布尔属性都为true
然而,要记住的最重要的概念是
属性表示它与选中的属性不对应。这个
属性实际上对应于defaultChecked属性和
应仅用于设置复选框的初始值。这个
选中的属性值不随对象的状态而更改
复选框,而已选中的属性则不会。因此,
确定是否选中复选框的跨浏览器兼容方式是
使用该属性
那你为什么不能用attr呢?我只是想知道为什么prop不能得到这个值。我用任何有用的东西。这只是一个一般性的问题。有些人说attr能得到接近的东西,但不是实际的价值。道具比属性好。但是我发现道具总是不能得到我想要的东西。看一看,我相信它能详细解释你的问题。答案是:“属性值只能是字符串,而属性可以是任何类型。例如,选中的属性是布尔值,样式属性是一个对象,每个样式都有单独的属性,大小属性是一个数字。”嗨,亚当,我也读了这篇文章。但各地都以checked为例。所以我这么说是对的。用于检查属性。我们用道具比较好。其余的使用attr?可能重复的
$(this).prop("supportdec");
$(this).prop("data-supportdec");