제출을 클릭하면 ID가 "fn_warn"인 내 매개 변수가 표시되기를 원합니다.
내 html 및 js 코드는 다음과 같습니다.
<!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>
CSS 규칙은 속성이 아닙니다. style
규칙이 인라인이므로 대신 속성을 사용하십시오 .
function tada(){
var x = document.getElementById("fn_warn");
x.style.visibility = "visible";
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다