js实时获取input数据

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>on用onpropertychange,oninput事件解决onchange事件的不足 by koyoz.com</title>
<style type="text/css">
*{font-size:14px;font-family:‘Comic Sans MS‘, Verdana}
body {margin-left:20px}
</style>
</head>
<body>
<p>使用onchange事件: </p>
<input type="text" id="txt1" />
<p>使用onpropertychange/oninput事件: </p>
<input type="text" id="txt2" />
<p>结果:</p>
<input type="text" id="txt" />

<script type="text/javascript">
var $ = function(o) {
return document.getElementById(o)
};
$(‘txt1‘).onchange = function() {
$(‘txt‘).value = this.value;
}
$(‘txt2‘).onpropertychange = function() {
$(‘txt‘).value = this.value;
}
if (window.addEventListener) {
$(‘txt2‘).addEventListener(‘input‘, function() {$(‘txt‘).value = this.value}, false);
}
</script>
</body>
</html>

JQ:

$("#textboxID").bind("propertychange", function() { 
alert($(this).val()); 
});

时间: 2024-08-05 22:22:39

js实时获取input数据的相关文章

JS实时获取输入框中的值

实时获取input输入框中的值需要oninput和onpropertychange属性来实现.原因是onpropertychange属性为IE专属,而oninput属性支持大部分浏览器包括IE9及以上的版本. oninput与onpropertychange失效的情况: oninput事件:1. 在脚本中改变value时,不会触发:2.从浏览器的自动下拉提示中选取时,不会触发. 例如: var testinput = document.createElement('input'); if('on

一个实时获取股票数据的安卓应用程序

关键字:Stock,股票,安卓,Android Studio. OS:Windows 10. 最近学习Android应用开发,不知道写一个什么样的程序来练练手,正好最近股票很火,就一个App来实时获取股票数据,取名为Mystock.使用开发工具Android Studio,需要从Android官网下载,下载地址:http://developer.android.com/sdk/index.html.不幸的是Android是Google公司的,任何和Google公司相关的在国内都无法直接访问,只能

js中获取input中所输入的值

<script type="text/javascript"> function huoqu(){ var G=document.getElementById('value').value; alert(G); } </script> <body> <div class="containter"> <div class="row"> <div class="md-col-

JS实时获取浏览器窗口尺寸 .

给div实时设置宽度 <div id="detail" style="width: 100%; overflow: scroll;"> </div> <script type="text/javascript">    var winWidth = 0;    var winHeight = 0;    function findDimensions() //函数:获取尺寸    {        //获取窗口

实时获取input输入框中的值

//输入框正在输入时 $("#ipt").on('input',function(){ if(!($('#ipt').val()=='')){ $(".cancle_ico").removeClass('hide'); }else{ $(".cancle_ico").addClass('hide'); } }) //输入框得到焦点时 $("#ipt").on('focus',function(){ if(!($('#ipt')

JS循环获取input的值

遍历class为input-text的文本框,获取值 $(".input-text").each(function(){ vals+=$(this).val()+','; }); 当然获取具有相同class的也可试用.jquery的各种选择器都是可用的.

js实时获取并显示当前时间的方法

用angular实时获取本地localStorage数据,实现一个模拟后台数据登入的效果

研究了一上午,终于做出了,实时获取本地localStorage来模拟注册登入~~~ <!DOCTYPE html><html><head lang="en"><meta charset="UTF-8"><title>我们虽然很穷,但是我们有梦想</title><script src="angular.js"></script></head>

ajax实时获取下拉数据

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> ajax实时获取下拉数据</pre> <style><!-- .input_s{ position:relative} .input_s ul{ list-style:none; margin:0; padding:0; width:200px; border:1px solid #cc