HTML:
<p><b id="msg" name="msg" style="visibility:hidden; color:#3399ff;">msg</b></p>
JS:
$('#url').on('change keyup paste',function(){
$('#msg')style.visibility('visible');});
我该怎么办?
答案 0 :(得分:4)
你混合了Javascript和Jquery。
使用Jquery,只需使用函数css()
$("#msg").css('visibility', 'visible');
或使用纯Javascript
document.getElementById("msg").style.visibility = "visible";
答案 1 :(得分:1)
使用jQuery,您可以使用.css
方法,如下所示:
$(document).ready(function () {
$('#msg').css('visibility', 'visible');
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p>
<b id="msg" name="msg" style="visibility:hidden; color:#3399ff;">message</b>
</p>
答案 2 :(得分:0)
$(document).ready(function(){
$('#msg').css('visibility','visible')
//or: initial => Sets this property to its default value
$('#msg').css('visibility','initial')
//or: inherit => Inherits this property from its parent element.
$('#msg').css('visibility','inherit')
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p><b id="msg" name="msg" style="visibility:hidden; color:#3399ff;">msg</b></p>