PDA

View Full Version : مبتدی: مشکل نمایش دادن یک کادر زمانی که روی دکمه کلیک می کنیم



hashtgerd2
جمعه 14 خرداد 1395, 20:02 عصر
سلام
می خوام وقتی دکمه رو میزنم یک نوشته ظاهر بشه
ولی تابع اصلا اون خط کد رو اجرا نمی کنه


<html>
<head>
<title>
session 3
</title>
<style type="text/css">
.y{
width: 200px ; height: 50px ;
font-size: 25px ; background-color: #a0f ;
}
</style>

</head>


<body>

<script type="text/javascript">

function aaa(){

<div id="d"> امتحان نزدیک است </div>
}
</script>

<button onclick="aaa()"> نمایش </button>



</body>
</html>

hashtgerd2
جمعه 14 خرداد 1395, 21:51 عصر
خودم حلش کردم


<html>
<head>
<title>
session 3
</title>


</head>


<body>





<script>
function myFunction() {
document.getElementById("y").textContent = "روز امتحان";
document.getElementById("y").style.backgroundColor = "lightblue";
}
function myFunction2() {
document.getElementById("y").textContent = "";
}
</script>


<center>
<button onmouseover="myFunction()" onmouseleave="myFunction2()">Try it</button>



<p id="y" > </p>
</body>
</html>