为了账号安全,请及时绑定邮箱和手机立即绑定

我想设置点击完按钮以后,他会显示"p元素class值为two"..但是我的代码显示不了,有大神指点下吗?


<style type="text/css">

    input{

font-size:10px;

}

.one{

width:200px;

}

.two{

font-size:18px;

color:#F00;

}

</style>

   

    

</head>


<body>

<p id="con" class="one">JavaScript</p>

<form>

   <input type="button" value="点击更改" onclick="modifyclass()">

</form>



  <script type="text/javascript">

   var mychar=document.getElementById("con");

   document.write("p元素Class值为:" + mychar.className+"</br>")

   function modifyclass(){

   mychar.className="two";

   document.mychar.innerHTML("p元素Class值为:two");

 

   }

   </script>


正在回答

1 回答

 document.mychar.innerHTML("p元素Class值为:two");改成  mychar.innerHTML="p元素Class值为:two";

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

我想设置点击完按钮以后,他会显示"p元素class值为two"..但是我的代码显示不了,有大神指点下吗?

我要回答 关注问题
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号