behzad behzad - 8 months ago 41
jQuery Question

Why jquery not set visiblity to div visible css properties?

I'm new in

,have a this div into my web page:

<div class="alert alert-success alert-dismissible" id="Message" style="visibility: hidden;" >
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<strong>Success!</strong> Indicates a successful or positive action.

write this jquery code:

$(".Message").css("visibility", "visible");

but that code can't set visible property to visibility ,what happen?how can i solve that problem?thanks.

Answer Source

It has to be: $("#Message").css("visibility", "visible");

As you are selecting an element by its ID For $('.Message'), the class name has to be 'Message'