最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - To make div visible using jQuery - Stack Overflow

programmeradmin3浏览0评论

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
Add a ment  | 

2 Answers 2

Reset to default 4

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

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!

发布评论

评论列表(0)

  1. 暂无评论