|
//獲取 文本框的值 <script type="text/javascript">
/** js獲取 */
var test = document.getElementById("test");
var text1 = test.innerHTML; //方法1
var text2 = test.value; //方法2
//注,innerText是獲取不到值的
/** jq獲取 */
var text3 = $("#test").val(); //方法1
var text4 = $("#test").text(); //方法2
var text5 = $("#test").html(); //方法3
</script>js 設(shè)置 textarea 內(nèi)容 <script type="text/javascript">
function change(){
/** js設(shè)置 */
var test = document.getElementById("test");
test.innerHTML = "你好,地球!"; //方法1
test.value = "你好,中國!"; //方法2
test.innerText = "綠色地球!"; //方法3
/** jq設(shè)置 */
$("#test").html("你好、我好、大家好!"); //方法1
$("#test").val("幸福的日子"); //方法2
$("#test").text("html好學(xué)"); //方法3
}
</script>
|
|
|