The examples in this article share the JS code of synchronous text box content for your reference. The specific content is as follows
Illustration 1
<html><body><script language="JavaScript" type="text/javascript"> function addEvent(eventHandler) { var tags = document.getElementsByTagName('input'); for(var i=0;i<tags.length;i++) { if(tags[i].getAttribute('url') == 'true') { if(tags[i].addEventListener) { tags[i].addEventListener('keyup',eventHandler,true); } else { tags[i].attachEvent('onkeyup',eventHandler); } } } } function addInput(e) { var obj = e.target ? e.target : e.srcElement; var tags = document.getElementsByTagName('input'); for(var i=0;i<tags.length;i++) { if(tags[i].getAttribute('url') == 'true'&&tags[i]!=obj) { tags[i].value = obj.value; } } } window.onload = function() { addEvent(addInput); }</script><p> <input id="addr_more1" size="35" value="" name="addr_more1" url="true" /></p><p> <input id="addr_more2" size="35" value="" name="addr_more2" url="true" /></p><p> <input id="addr_more3" size="35" value="" name="addr_more3" url="true" /></p><p> <input id="addr_more4" size="35" value="" name="addr_more4" url="true" /></p></body></html>Figure 2
<html><head><script type="text/javascript" src="jquery-1.4.4.min.js"></script> <script type="text/javascript"> function getNM(id) { var name2 = $("#"+id+"").val(); if (name2 != "") { for(var i=3;i<6;i++) $("#NM"+i+"").val(name2); } } </script></head><body> <input type="text" id="NM1" value="" /> <input type="text" id="NM2" value="" /> <input type="text" id="NM3" value="" onkeyup="getNM(this.id)"/> <input type="text" id="NM4" value="" onkeyup="getNM(this.id)"/> <input type="text" id="NM5" value="" onkeyup="getNM(this.id)"/></body></html>Need to quote <script type="text/javascript" src="jquery-1.4.4.min.js"></script>
The above is all the content of this article. I hope it will be helpful to everyone's learning and I hope everyone will support Wulin.com more.