简体   繁体   English

显示一个隐藏元素的jQuery

[英]show a hidden element jquery

I don't know why it doesn't work with bootstrap modal . 我不知道为什么它不适用于bootstrap modal

I want to show the hidden element. 我想显示隐藏的元素。

I tried 3 different way's 我尝试了3种不同的方式

(with display:none; and in javascript a did $('..').show() , (with display:none; and in javascript a $('..')。show()

visibility:hidden and in the javascript $('..').css('visibilty','visible') , 可见性:隐藏在javascript $('..')。css('visibilty','visible')中

and the class="hidden" and in the javascript $('..').removeClass('hidden') ) class =“ hidden”以及javascript $('..')。removeClass('hidden')

here is my code : 这是我的代码:

 $('.btn[id="zaki"]').click(function() { $('#show_1524').show(); }) 
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <button class="btn btn-danger" id="zaki">ilyes_show</button> <div> <p style="display:none;" id="show_1524">..................</p> </div> 

Though your code works fine but since inline styles have highest specificity replace the inline style with a class and then on button click use removeClass to remove it 尽管您的代码可以正常工作,但是由于内联样式具有最高的特异性,所以用类替换内联样式,然后在按钮上单击“ removeClass将其删除。

 $('.btn[id="zaki"]').click(function() { $('#show_1524').removeClass('hideElem'); }) 
 .hideElem { display: none; } 
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <button class="btn btn-danger" id="zaki">ilyes_show</button> <div> <p class="hideElem" id="show_1524">..................</p> </div> 

 $('.btn[id="zaki"]').click(function() { $('#show_1524').show(); }) $('.btn[id="zaki-hide"]').click(function() { $('#show_1524').hide(); }) 
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"> </script> <button class="btn btn-danger" id="zaki">ilyes_show</button> <button class="btn btn-danger" id="zaki-hide">ilyes_hide</button> <div> <p style="display:none;" id="show_1524">..................</p> </div> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM