為什么我輸入的代碼運行不了
? ? ? <input type="button" value="改變顏色" onClick="changeColor()"> ?
? ? <input type="button" value="改變寬高" onClick="changeSize()">
? ? <input type="button" value="隱藏內容" onClick="hidetext()">
? ? <input type="button" value="顯示內容" onClick="showtext()">
? ? <input type="button" value="取消設置" onClick="offset()" >
? </form>
? <script type="text/javascript">
? ? var txt=document.getElementById("txt");
{
? ? function changeColor(){
? ? ? ?txt.style.color="red";?
? ? ? ?txt.style.backgroundColor="#ccc";
? ? }
? ? function changeSize(){
? ? ? ? txt.style.width="500px";
? ? ? ? txt.style.height="700px";
? ? }
? ? function hidetext(){
? ? ? ? txt.style.display="none";
? ? }
? ? function showtext(){
? ? ? ? txt.style.display="block";
? ? }
? ? function offset(){
? ? var mychar=confirm("確定要重置所有設置嗎?");
? ? if(mychar==true){
? ? ? ? txt.removeAttribute('style');
? ? }
? ??
? ? }
}
2015-11-04
這些函數外面包含的{}是怎么回事???