I'm successfully using Simple Modal to launch a modal when a button is clicked, however, I want the page to scroll to the top first. I tried placing an anchor tag at the top of the page and referencing it in my link using , but it didn't work. The Simple Modal still worked, but it didn't scroll to the top of t开发者_C百科he page first. Is there a way to edit the simple modal javascript to make it first scroll to the top of the page before the modal is opened?
use JavaScript before you call your modal: window.scrollTo(0,0)
Use a callback: http://www.ericmmartin.com/projects/simplemodal/#options
$('#modalContent').modal({
onOpen: function () {
$('html, body').scrollTo(0, 0);
}
});
精彩评论