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();
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();
Share
Improve this question
edited Oct 12, 2017 at 12:31
Shiladitya
12.2k17 gold badges28 silver badges42 bronze badges
asked Apr 17, 2015 at 8:59
MosesMoses
692 silver badges9 bronze badges
3
- 1 did you try to add this js in $(document).ready(function () { ... your code ..} – Aleksandar Gajic Commented Apr 17, 2015 at 9:02
- @Alex G My problem is If i set visible false div in design it is not working if i remove false in design i can make to visible/invisible – Moses Commented Apr 17, 2015 at 9:03
- 1 oh, than instead of visible="false" set style="display: none;" – Aleksandar Gajic Commented Apr 17, 2015 at 9:04
2 Answers
Reset to default 4visible="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
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!