目前我在实现 Javascript 时遇到了一个问题。链接在这里
http://jsfiddle.net/joplomacedo/WzA4y/
这是有效的而且我正在使用 Microsoft Visual Studio 2010,并且我有小文件一个是 html,另一个是 CSS,我使用下面的代码中的 Javscript,但这不像链接上面的 jsFiddle 那样工作。
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type="text/javascript"></script>
<script type="text/jscript" language="javascript">
var body = $('body'),
main = $('.main'),
open_modal = $('.open-modal'),
close_modal = $('.close-modal'),
modal_container = $('.modal-container'),
toggleModal = function() {
body.toggleClass('body-locked');
modal_container.toggleClass('dp-block');
};
open_modal.on('click', toggleModal);
close_modal.on('click', toggleModal);
</script>
</head>
<body>
<button class="open-modal">Button!</button>
<div class="modal-container dp-none">
<div class="modal">
<button class="close-modal">Close!</button>
</div>
</div>
</body>
</html>