<script> function show(){ var show = document.getElementById("showContent");//显示文本的对象 var content = document.getElementById("content");//输入文字的对象 show.innerHTML += content.value;//把两个相连接 }</script><h1 id="showContent">Hello World!</h1><input id="content" name="content"/><button onClick="show()">把内容加载在页面上</button>
在网页上动态创建节点 + getInnerText从文本框获得输入内容
<script language="javascript"> function copText(){ document.getElementById("t2").value=document.getElementById("t1").value; }</script><input type="text" id="t1" /><input type="text" id="t2" /><button onclick="copText()">try</button>
我写了个例子,你试试:<html><head><title>jsTest</title></head><body><select id="sel"><option>a</option><option>b</option></select><input type="text" id="txt"><input type="button" value="show" onclick="show()"></br><p id
我写了个例子,你试试:<html><head><title>jsTest</title></head><body><select id="sel"><option>a</option><option>b</option></select><input type="text" id="txt"><input type
代码:<!DOCTYPE html><html lang="en"><html><head><meta charset="UTF-8"><title>测试</title> <style>iframe{display: block;margin: 0 auto;margin-top: 100px; }</style></head><body> <input type="text" id="text1" name="data"
实现点击按钮文本框内文字加粗的方式有以下两种方式: 1、直接修改或者添加css样式: $("button").click(function(){ $("input").css("font-weight","bold"); }); 2、添加相应的class类名使其加粗: $("button").click(function(){ $("input").addclass("fontbold"); });.fontbold{font-weight:bold};
<!62616964757a686964616fe4b893e5b19e31333363376438DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Title</title> <script> function set() { var a = document.getElementById("sss"); var d = document.
javascript部分 function checkNum(){ var oText = document.getElementById("textBox1"); var val = oText.val; if(parseInt(val)<0){ alert("你输入的数小于零"); } html部分 <input type="button" onclick = "checkNum()" value="click" /> <input type="text" id="textBox1" name="textBox1" /> }
给按钮添加事件 :<br>onclick="alert(document.getElementById('文本框的id').value);"