Moses
Moses

Reputation: 69

To make div visible using jQuery

In the below code I have a div I have set to false and I want to make visible true using jQuery. If I remove visible false in div I can make visible. Please help me to do this.

<div id="divmaterialconsumption" runat="server" visible="false"  ></div>

JavaScript:

$('#<%=divmaterialconsumption.ClientID %>').show();

Upvotes: 0

Views: 5958

Answers (2)

Deadpool
Deadpool

Reputation: 8240

Do the program as follows:

<div id="divmaterialconsumption" style="display:none;"  ></div>

jQuery:

$(document).ready(function(){
  $('#but1').click(function(){  //assuming event taking by click of a btn
   $('#divmaterialconsumption').css('display','block');
 });
});

OR

 $('#divmaterialconsumption').show();

I hope that solves your issue!

Upvotes: 4

iCollect.it Ltd
iCollect.it Ltd

Reputation: 93631

visible="false" on a server control (e.g. runat="server") stops it being rendered at all!

Instead hide it with style="display:none" and get rid of the visible="false"

jQuery's show() method can then change the style to display: block

Upvotes: 4

Related Questions