两个input可能会用到的小方法
1.一个普通的input元素,在不被 form包裹的时候,如何跳转或搜索
var oInput = document.getElementsByTagName('input')[0];
oInput.addEventListener('keyup',function(event){
var event = event || window.event;
if(event.keyCode === 13) {
location.href = 'http://www.baidu.com/s?wd=' + this.value;
}
})
2.多个input按enter输入下一项
document.addEventListener('DOMContentLoaded', function () {
var oInputs = document.getElementsByTagName('input');
var len = oInputs.length;
for (var i = 0; i < len; i++) {
console.log(i);
(function (i) {
oInputs[i].addEventListener('keydown', function (event) {
event = event || window.event;
console.log(event.keyCode);
if (this.type != 'submit' && event.keyCode === 13) {
event.preventDefault();
oInputs[i + 1].focus();
}
})
})(i)
}
})
两个input可能会用到的小方法的更多相关文章
- 两个input之间有空隙,处理方法
修改css,给前边一个input添加一个左浮动. <input id="day" type="button" value="日" ...
- 微信小程序-两个input叠加,多次点击字体变粗或闪动
问题描述: 当两个input叠加,多次点击input框, placeholder 字体变粗或input框闪动.如图: 代码: <!-- 最上层input-1 --> <input p ...
- 看起来像一个输入框的input,实际上是有两个input
看起来像一个输入框的input,实际上是有两个input
- 两个input在同一行连着不留缝隙
方法1:让两个input 连在一起写 不换行 <div class="inputDiv"> <input type="text" placeh ...
- 【medium】4. Median of Two Sorted Arrays 两个有序数组中第k小的数
There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two ...
- 两个input在一行让它们能对齐
input明明写在同一行,高度也一样,在不同的浏览器或者手机上显示却不一样,经常会出现这样的情况 <input type="text" name="verify&q ...
- HTML问题 | 两个Input在同一行连着不留缝隙
方法1:让两个 input 连在一起写 不换行 <div class="inputDiv"> <input type="text" place ...
- 【iview input 回车刷页面bug】input 就一个的时候 有form的时候 回车会刷页面,如果就一个input,可以不要form,或者form里面两个input 将一个input v-show false 就可以了
[iview input 回车刷页面bug]input 就一个的时候 有form的时候 回车会刷页面,如果就一个input,可以不要form,或者form里面两个input 将一个input v-sh ...
- 在reset css后两个input之间还是出现默认间隔的问题。
<div class="search_box fl"> <input type="text" class="search_text& ...
随机推荐
- Servlet实现国际化
以下内容引用自http://wiki.jikexueyuan.com/project/servlet/internationalization.html: 三个重要术语: 国际化(i18n):这意味着 ...
- 联想M7400打印机加粉墨了还是显示没有粉墨
联想M7400打印机加粉墨了还是显示没有粉墨?想必有很多的办公人士发现这个难题吧.其实很简单的! 先说下打印机的原理,打印机粉墨一边用的时候系统也在计数,当我们打印机加好墨后但打印机是不知道已经加好 ...
- 一 hadoop 相关介绍
hadoop 相关介绍 hadoop的首页有下面这样一段介绍.对hadoop是什么这个问题,做了简要的回答. The Apache™ Hadoop® project develops open-sou ...
- C# 图片识别(支持21种语言)转
来自:http://www.cnblogs.com/stone_w/archive/2011/10/08/2202397.html 图片识别的技术到几天已经很成熟了,只是相关的资料很少,为了方便在此汇 ...
- CSDN 夏令营程序 试题分析 (2)
题目:若须要在O(nlogn)(以2为底)的时间内完毕对数组的排序.且要求排序是稳定的,则可选择的排序方法是: A.高速排序 B.堆排序 C.归并排序 D.直接插入 ...
- 【CV论文阅读】生成式对抗网络GAN
生成式对抗网络GAN 1. 基本GAN 在论文<Generative Adversarial Nets>提出的GAN是最原始的框架,可以看成极大极小博弈的过程,因此称为“对抗网络”.一般 ...
- 【CV论文阅读】+【搬运工】LocNet: Improving Localization Accuracy for Object Detection + A Theoretical analysis of feature pooling in Visual Recognition
论文的关注点在于如何提高bounding box的定位,使用的是概率的预测形式,模型的基础是region proposal.论文提出一个locNet的深度网络,不在依赖于回归方程.论文中提到locne ...
- Vmware worksiation中使用ISO
Vmware技巧: 用ISO安装系统,需要添加2个CD设备. IDE 1 中选择 autoinst.iso IDE 2 中选择 “要安装的系统”.iso 简单讲:Vmware模拟机上需要模拟两次i ...
- 从epoll构建muduo-13 Reactor + ThreadPool 成型
mini-muduo版本号传送门 version 0.00 从epoll构建muduo-1 mini-muduo介绍 version 0.01 从epoll构建muduo-2 最简单的epoll ve ...
- nginx-1.5.10 之mips编译到RT5350
编译nginx-1.5.10一般须要下面库的支持:pcre,zlib,openssl 此次编译nginx-1.5.10使用的库版本号分别为pcre-8.34:openssl-1.0.0l:zlib-1 ...