开发者

Accessing HTML custom attributes

I want to know is there any way to add a custom attribute to the a HTML element.

For example ,

<input type="text" name="txtNAME1" displayName="dname1" />

In the above example the custom attribute "displa开发者_JAVA技巧yName" is not a standard HTML attribute. So I want to know if I can define the same and push the intended value to the server and access the same attribute's value.

Thanks in advance!


Which language are you using? You can do this in C# using

<input type="text" name="txtNAME1" displayName="dname1" runat="server" id="test" />

Then, in the code behind:

test.Attributes["displayName"];

You can also access it in jQuery with

$('test').attr('displayName')

and send it through to the server via a handler.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜