显示隐藏的输入javascript/jquery

jav*_*ava 0 html javascript jquery

为什么隐藏的形式在失去焦点时不显示?离开输入时警报很好,但其他隐藏的形式仍然不存在.

HTML

<body>
   <input type="text" id="myinput" value="">
   <input type="hidden" id="validation_message_email" value="enter a valid email">
</body>
Run Code Online (Sandbox Code Playgroud)

JavaScript的

window.onload = function() {
   $("#myinput").blur(myAlert);
};

function myAlert() {
   alert("This input field has lost its focus.");
   $("#validation_message_email").show();
}
Run Code Online (Sandbox Code Playgroud)

Ano*_*shi 5

你不能显示那样的隐藏输入.一个span会更适合这个目的,

<input type="text" id="myinput" value="">
<span style="display:none"  id="validation_message_email">enter a valid email</span>
Run Code Online (Sandbox Code Playgroud)