Reputation: 73
i want my para with id "fn_warn" to be visible when submit is clicked.
my html and js code is as,
<!DOCTYPE HTML>
<html>
<head>
</head>
<body>
First name
<input id="first_name" type="text"/>
<p id="fn_warn" style=" visibility: hidden; color: red;">#Please enter a valid name...</p>
<input class="button" onclick="tada();" type="submit" value="Submit" /> <input class="button" type="reset" />
</body>
</html>
<script>
function tada(){
var x= document.getElementById("fn_warn");
x.setAttribute("visibility","visible");
}
</script>
Upvotes: 1
Views: 1136
Reputation: 59859
CSS rules are not attributes. Use the style
property instead since the rule is inline:
function tada(){
var x = document.getElementById("fn_warn");
x.style.visibility = "visible";
}
Upvotes: 1