欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

點擊button獲取text內(nèi)容并改變樣式的js實現(xiàn)

 更新時間:2014年09月09日 10:45:49   投稿:whsnow  
這篇文章主要介紹了點擊button獲取text內(nèi)容并改變樣式的js實現(xiàn),經(jīng)測試非常實用,需要的朋友可以參考下

需求:點擊button獲得input框中選中的內(nèi)容,讓選中的內(nèi)容變紅,

實現(xiàn):代碼如下

<!DOCTYPE HTML>

<html>

<head>

<meta http-equiv="content-type" content="text/html;charset=utf-8">

<title>Test</title>

<style type="text/css">

div{

display: none;

}

</style>

</head>

<body>

<input type="text" id="txt" value="" /> 

<input type="button" value="獲取文本框內(nèi)的值" id="btn" onclick="getText();"/>

<div id="showText">

</div>

<script type="text/javascript">

function getText () {

var showText = document.getElementById("showText");

showText.style.display = "block";

showText.style.color = "red";

showText.innerHTML=document.getElementById("txt").value;

}

</script>

</body>

</html>

效果:

相關文章

最新評論