求助JS自动输入INPUT的方法 有两个input,第一个输入的是十个数字,第二个input自动获得第一个的后六位,当光标移动到第二个input时,自动输入获得的后六位,应该怎么实现? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <input type="text" id="a" /><input type="text" id="b" />window.onload = function() { var b = document.getElementById("b"); b.focus = function() { var a = document.getElementById("a").value; a = a.substring(a.length - 6 - 1, a.length); b.value = a; };}; window.onload = function() { var b = document.getElementById("b"); b.onfocus = function() { var a = document.getElementById("a").value; a = a.substring(a.length - 6 - 1, a.length); b.value = a; };}; <body><input type="text" id="f" /><input type="text" id="s" /><script>window.onload = function() { var f = document.getElementById('f'), s = document.getElementById('s'); s.onfocus = function() { this.value = f.value.slice(-6); } }</script></body> 献个丑。jQuery实现<html><head><script type="text/javascript" src="jquery.js"></script><script type="text/javascript">$().ready(function(){ $('#b').focus(function(event){ $('#b').val($('#a').val().substring(5)); });});</script></head><body><input type="text" id="a" value="input abc 1234"/><input type="text" id="b" /></body></html> function pass() { var b = document.getElementById("password"); b.onfocus = function() { var a = document.getElementById("no").value; a = a.slice(4); b.value = a; 求能在IE9+版本(非兼容模式)和火狐下能用的一句脚本改编 懂htmlarea编辑器 的各位大虾`恩人,求您进来看一眼吧! 大家看一下这段js代码,怎么理解,有没有简单的实现方法? 传参问题 JSP页面搜索引擎,在搜索框中输入关键字,在结果也中返回结果,结果标题中的关键字需要高亮显示,不知如何实现,请高手帮忙,谢谢! 如何让网页在一段时间内刷新? 即时显示消息 網頁如何防止復制? 求一段简单的代码,关于提交按钮的disabled----------解决保证立即给分 网页上禁用另存为,不要直接屏蔽右键菜单的 如何给页面上的每一个链接增加声音事件 错误在哪?
<input type="text" id="b" />
window.onload = function() {
var b = document.getElementById("b");
b.focus = function() {
var a = document.getElementById("a").value;
a = a.substring(a.length - 6 - 1, a.length);
b.value = a;
};
};
window.onload = function() {
var b = document.getElementById("b");
b.onfocus = function() {
var a = document.getElementById("a").value;
a = a.substring(a.length - 6 - 1, a.length);
b.value = a;
};
};
<body>
<input type="text" id="f" />
<input type="text" id="s" />
<script>
window.onload = function() {
var f = document.getElementById('f'),
s = document.getElementById('s');
s.onfocus = function() {
this.value = f.value.slice(-6);
}
}
</script>
</body>
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$().ready(function(){
$('#b').focus(function(event){
$('#b').val($('#a').val().substring(5));
});
});
</script>
</head><body>
<input type="text" id="a" value="input abc 1234"/>
<input type="text" id="b" />
</body>
</html>
function pass() {
var b = document.getElementById("password");
b.onfocus = function() {
var a = document.getElementById("no").value;
a = a.slice(4);
b.value = a;