Display Bootstrap Modal using javascript onClick

后端 未结 4 1507
时光取名叫无心
时光取名叫无心 2021-02-03 20:48

I need to be able to open a Twitter bootstrap modal window using the onClick=\"\" or similar function. Just need the code to go into the onClick=\"\".

4条回答
  •  太阳男子
    2021-02-03 21:33

    A JavaScript function must first be made that holds what you want to be done:

    function print() { console.log("Hello World!") }
    

    and then that function must be called in the onClick method from inside an element:

     ... 
    

    You can learn more about modal interactions directly from the Bootstrap 3 documentation found here: http://getbootstrap.com/javascript/#modals

    Your modal bind is also incorrect. It should be something like this, where "myModal" = ID of element:

    $('#myModal').modal(options)
    

    In other words, if you truly want to keep what you already have, put a "#" in front GSCCModal and see if that works.

    It is also not very wise to have an onClick bound to a div element; something like a button would be more suitable.

    Hope this helps!

提交回复
热议问题