javascript - Click on Link using jQuery -
i trying automatically click link when page loads using jquery. have done in past projects, not able work now. here code:
<script type="text/javascript"> $(document).ready(function(){ $(".btn-warning").trigger("click"); }); </script> <!-- modal --> <a href="#mymodal2" role="button" class="btn btn-warning" data-toggle="modal">confirm</a> <div id="mymodal2" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="mymodallabel2" aria-hidden="true"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button> <h3 id="mymodallabel2">alert header</h3> </div> <div class="modal-body"> <p>body goes here...</p> </div> <div class="modal-footer"> <button data-dismiss="modal" class="btn green">ok</button> </div> </div>
i believe data-toggle="modal"
part of code messing things up. if remove this, modal not work @ all. maybe need use other click
value?
thanks
since said using bootsrap. suggest following (below) instead of using click event.
<script type="text/javascript"> jquery(window).load(function($){ $('#mymodal2').modal('show'); }); </script>
fiddle: http://jsfiddle.net/rsdpt/1/
another fiddle (thanks @fakerainbrigand): http://jsfiddle.net/nhd9u/2/
Comments
Post a Comment