1 清洗表名: <input type="text" name="fileName"/><br/>
1 var fileName = document.getElementsByName("fileName");

document.getElementsByName来获取一个包含页面中所有指定Name元素的对象数组。

比如:fileName[0].value来获取这个对象数组里的第一个标签的value值。

1 清洗字段: <input type="text" id="fieldName"/><br/>
1 var fieldName = document.getElementById("fieldName").value;

getElementsByName和getElementById的区别的更多相关文章

  1. getElementsByName和getElementById获取控件

    js对控件的操作通常使用getElementsByName或getElementById来获取不同的控件进行操作 getElementsByName() 得到的是一个array, 不能直接设value ...

  2. getElementById,getElementsByName,getElementsByTagName的区别

    1.getElementById 作用:一般页面里ID是唯一的,用于准备定为一个元素 语法: document.getElementById(id) 参数:id :必选项为字符串(String) 返回 ...

  3. getElementsByTagName 、 getElementsByName 、getElementById区别

    WEB标准下可以通过getElementById(), getElementsByName(), and getElementsByTagName()访问DOCUMENT中的任一个标签: getEle ...

  4. document.getElementById()与 $()区别

    document.getElementById()返回的是DOM对象,而$()返回的是jQuery对象 什么是jQuery对象? ---就是通过jQuery包装DOM对象后产生的对象.jQuery对象 ...

  5. getElementByName()和getElementById的区别

    因为在属性中,id时唯一的,getElementById取出的是一个元素但是可以出现相同的name,取到的是一个Array ,getElementsByName取出的是数组 记录代码如下: <! ...

  6. getElementsByName和getElementById

    1: 今天分享工作中遇到的一个小细节 1.1 先介绍一下两个方法分别是: 1.2 getElementById()  :可返回对拥有指定 ID 的第一个对象的引用,如果您需要查找文档中的一个特定的元素 ...

  7. $()和getElementById()的区别

    jQuery的成功多归功于其强大的选择器. 然而,相信不少初学jQuery的同学都会遇到下面的问题. 在javascript下,我们可以根据getElementById()来获取页面元素.如下: va ...

  8. document.write与document.getElementById的区别

    document.write改变的是整个HTML页面(文档),document.getElementById("demo").innerHTML= 改变的是局部属性

  9. js 原生 document.querySelectorAll document.getElementsByTagName document.querySelector document.getElementById的区别

    1.querySelector只返回匹配的第一个元素,如果没有匹配项,返回null.  2.querySelectorAll返回匹配的元素集合,如果没有匹配项,返回空的nodelist(节点数组). ...

  10. jquery 中的 $(“#”) 与 js中的document.getElementById(“”) 的区别

    以前没注意过,认为jquery 中的 $("#") 与 document.getElementById("") 是一回事,指的是同一个东西. 这次项目开发在使用 ...

随机推荐

  1. 我又踩坑了!如何为HttpClient请求设置Content-Type?

    1. 坑位 最近在重构认证代码,认证过程相当常规: POST /open-api/v1/user-info?client_id&timstamp&rd=12345&sign=* ...

  2. win32-FileTimeToSystemTime的使用

    #include <Windows.h> #include <iostream> #include <string> #pragma warning(disable ...

  3. 使用go module导入本地包

    go module是Go1.11版本之后官方推出的版本管理工具,并且从Go1.13版本开始,go module将是Go语言默认的依赖管理工具. 前提 假设我们有learngo和mypackage两个 ...

  4. 【Azure 应用服务】Azure Function (PowerShell) 执行时报错 "out of memory"

    问题描述 在Azure Function App服务中,创建一个PowerShell脚本的函数,遇见了OOM(Out Of Memory)的异常报错: 2022-01-10T07:44:37 Welc ...

  5. 【Azure 应用服务】Azure Function App Linux环境下的Python Function,安装 psycopg2 模块错误

    问题描述 在Azure中创建Function App(函数应用), 用以运行Python代码(Python Version 3.7). 通过VS Code创建一个HttpTrigger的Functio ...

  6. 【Azure Redis 缓存】Redis导出数据文件变小 / 在新的Redis复原后数据大小压缩近一倍问题分析

    问题描述 使用 Azure Cache for Redis 服务,在两个Redis服务之间进行数据导入和导出测试.在Redis中原本有7G的数据值,但是导出时候发现文件大小仅仅只有30MB左右,这个压 ...

  7. C++//vector存放自定义数据类型

    1 //vector存放自定义数据类型 2 3 #include <iostream> 4 #include <string> 5 #include<fstream> ...

  8. 开源的 Sora 复现方案,成本降低近一半!

    近日,开发 ChatGPT 的 OpenAI 公司又放出王炸 Sora,一个可以根据文本生成视频的 AI 模型. 上图就是 OpenAI 公布的 Sora 生成的视频片段,可以毫不夸张地说 Sora ...

  9. C++入门编程----C++运算符(8)

    什么是运算符 运算符是让程序执行特定的数学或逻辑操作的符号,用来表示针对数据的特定操作,也称之为操作符.C++运算符分别有算术运算符.关系运算符.逻辑运算符.赋值运算符.位运算符.移位运算符.size ...

  10. Ubuntu 离线安装软件包

    Ubuntu 离线安装软件包 关键词:apt-offline,Ubuntu,dpkg,.deb 本文使用的ubuntu20.04,当机器无法连接外网时,我们使用离线的方式安装软件包. 离线安装的软件包 ...