<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication2.Default" %>
<!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 runat="server">
<title></title>
<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
$(function () {
//兼容:IE6、IE7、IE8、Firefox、Opera、Chrome、Safari
if ($.browser.msie) {//IE浏览器
$("#TestTextBox1").get(0).onpropertychange = setTestTextBox2;
} else {//其他浏览器
$("#TestTextBox1").get(0).addEventListener("input", setTestTextBox2, false);
}
});
// 设置TestTextBox2的值
function setTestTextBox2() {
$("#TestTextBox2").val($(this).val());
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TestTextBox1" runat="server" TextMode="MultiLine" Width="200" Height="50"></asp:TextBox>
<asp:TextBox ID="TestTextBox2" runat="server" TextMode="MultiLine" Width="200" Height="50"></asp:TextBox>
</div>
</form>
</body>
</html>
实时监听js改变value,跨浏览器支持
最新推荐文章于 2019-01-12 18:33:24 发布