
JavaScript getElementByTag和getElementByName的区别
这里赋值的时候,txt1和txt2都没改变,但是删除掉了name属性就可以改变,为什么呢。getElementByTag取得所有input标签,给value赋值,为什么t...
这里赋值的时候,txt1和txt2都没改变,但是删除掉了name属性就可以改变,为什么呢。
getElementByTag取得所有input标签,给value赋值,为什么txt1和txt2的value值
没被改变 展开
getElementByTag取得所有input标签,给value赋值,为什么txt1和txt2的value值
没被改变 展开
展开全部
因为name重复了吧,ByTag是根据标签的名称获取标签,ByName是根据标签的name属性获取标签
展开全部
问答标题中你的两个方法名都写错了,而且你也没有贴赋值的代码。
getElementsByName 根据 id 或 name 属性查找。
When you use the getElementsByName method, all elements in the
document that have the specified NAME attribute or ID attribute value
are returned.
getElementsByTagName 根据 TagName查找,(例如 "INPUT")
Returns a collection of objects with the specified element name.
getElementsByName 根据 id 或 name 属性查找。
When you use the getElementsByName method, all elements in the
document that have the specified NAME attribute or ID attribute value
are returned.
getElementsByTagName 根据 TagName查找,(例如 "INPUT")
Returns a collection of objects with the specified element name.
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐于2016-02-19 · 知道合伙人软件行家
关注

展开全部
tag获取的为:html标签如:<input><span><div>...
name为:标签属性如:<input name="ni" type='text'><span name='sp'></span>
var ni = getElementByName('ni') //得到值为数组
var sp = getElementByName('sp') //得到值为数组
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询