Javascript appendChild名称属性 [英] Javascript appendChild name property

查看:82
本文介绍了Javascript appendChild名称属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我试图将属性添加到单选按钮输入中,特别是Javascript中的name属性。我将孩子附加到主要对象上,当我使用Object.setAttribute( name,value);然后检查附加输入的innerHTML,它甚至根本不包含name属性!

So I'm trying to add attributes to a radio button input, specifically the name attribute in Javascript. I'm appending children to a main object and when I use Object.setAttribute("name", value); and subsequently check the innerHTML of the appended input, it does not even contain a name property at all!

我猜我想念一些简单的东西,或者有一个解决这个问题的方法,但是我已经为这个问题努力了很长时间,但没有成功。我尝试使用Object.name = value和Object.nodeName = value直接访问属性(那是一个随机尝试)。

I'm guessing I'm missing something simple or there is a way around it but I've been wrestling with this problem for quite a while with no success. I tried accessing the property directly using Object.name = value and Object.nodeName = value (that one was a random try).

是否存在某种问题,其中IE6的javascript呈现引擎无法识别setAttribute( name,value)吗?

Is there some sort of problem in which IE6's javascript rendering engine does not recognize setAttribute("name", value)? Is there a way around it?

推荐答案

有一种解决IE的方法:

Here's a workaround for dealing with IE:

http://javascript.about.com/library/bliebug2.htm

http://www.thunderguy.com/semicolon/2005/05/23/setting-the-name-attribute-in-internet-explorer/

本质上,使用的方法是动态创建元素,而不是修改现有元素。

Essentially, the method used is to create the elements on the fly instead of modifying existing elements.

这篇关于Javascript appendChild名称属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆