Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

javascript - 模态显示onclick jQuery(Modal display onclick jquery)

I want to display modal on button click.(我想在按钮单击时显示模式。)

I've followed bootstrap documentation, but for some reason the modal isn't popping up.Here is my code:(我已经阅读了bootstrap文档,但是由于某种原因,模态没有弹出,这是我的代码:)

Modal:(模态:)

<div class="modal fade" id="commonModal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">

                </button>
            </div>
            <div class="modal-body">
                <p>.............</p>
            </div>
            <div class="modal-footer">
                ..........
            </div>
        </div>
    </div>
</div>

Button:(按键:)

 <button type="button" class="btn btn-secondary btn-view-details"
data-toggle="modal"> View Details</button>

Jquery:(jQuery:)

  $(document).ready(function(){
            $('button.btn-view-details').on('click', function () {
                $('#commonModal').modal('show');
            })
 })
  ask by Proteeti Prova translate from so

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

1 Reply

0 votes
by (71.8m points)

On your button, you can add data-target attribute and you don't need to trigger the popup via jQuery:(在按钮上,您可以添加data-target属性,并且不需要通过jQuery触发弹出窗口:)

<button type="button" class="btn btn-secondary btn-view-details"
data-toggle="modal" data-target="#commonModal"> View Details</button>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.9k users

...