Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
399 views
in Technique[技术] by (71.8m points)

javascript - 如何打开和关闭布尔玛模型Jquery切换属性(How to turn on and off Bulma Model Jquery toggle attribute)

My Bulma CSS framework model element is not toggling on and off when I wanted it to.(我的Bulma CSS框架模型元素在需要时不会切换。)

I made a function to add class "is-active" when I click on the show modal button but nothing happens.(当我单击显示模式按钮时,我做了一个添加类“ is-active”的函数,但没有任何反应。) Also, there weren't any error messages.(另外,没有任何错误消息。) $('#showModal').click(function(){ $('.modal').addClass('is-active'); }); $('.modal-close').click(function(){ $('.modal').removeClass('is-active'); }); <!-- Message--> <article class="message is-link is-vcentered"> <div class="message-body"> <p class="is-size-4">Eg text</p> <br> <button class="button is-link" id="showModal">Clic</button> </div> </article> <!--MODAL --> <div class="modal"> <div class="modal-background"></div> <div class="modal-content"> <h3>Hello world</h3> </div> <button class="modal-close is-large" aria-label="close"></button> </div>   ask by Sunchae Kim translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

works fine, can you reproduce your issue?(工作正常,您可以重现您的问题吗?)

$(document).ready(() => { const modal = $('.modal'); $('#showModal').click(function(){ modal.addClass('is-active'); }); $('.modal-close').click(function(){ modal.removeClass('is-active'); }); }); <link href="https://cdn.jsdelivr.net/npm/[email protected]/css/bulma.min.css" rel="stylesheet"/> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <!-- Message--> <article class="message is-link is-vcentered"> <div class="message-body"> <p class="is-size-4">Eg text</p> <br> <button class="button is-link" id="showModal">Clic</button> </div> </article> <!--MODAL --> <div class="modal"> <div class="modal-background"></div> <div class="modal-content"> <h3>Hello world</h3> </div> <button class="modal-close is-large" aria-label="close"></button> </div>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...