我有一个登录表单,我想用jQuery验证和重定向(如果用户名和密码是正确的),重定向不起作用.
这是我的代码:
$(document).ready(function() {
$('#lc-login').click(function() {
var username = $('#username').val();
var pass = $('#pass').val();
if (testUser(username) === true && testPass(pass) === true) {
window.location.replace("http://www.domain.com/home.html");
} else {
alert('warning message');
}
});
});
Run Code Online (Sandbox Code Playgroud)
我试着更换一下window.location.replace
,window.location.href
但仍然没有.我应该说testUser和testPass工作正常,因为如果我添加一个简单的alert('the validation is ok!')
,消息就出现在我的屏幕上.
我正在尝试使用mapbox.js创建一个经度和纬度选择器,我需要这个地图位于一个模式框中,当我点击"选择位置"按钮时会打开它.但是当这个模态打开时,地图不会完全呈现.
这是我的代码:
<div class="modal fade" id="chooseLocation" tabindex="-1" role="dialog" aria-labelledby="chooseLocation" aria-hidden="true">
<div class="Cadd-event-modal" style="width: 600px; margin: 0px auto; margin-top: 10%;">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title Cfont-1">Choose location</h4>
</div>
<div class="modal-body" style="width: 500px; margin: 0px auto;">
<div id='map'></div>
<div class='map-overlay'>
<label for='latitude'>latitude</label><br />
<input type='text' size='5' id='latitude' /><br />
<label for='longitude'>longitude</label><br />
<input type='text' size='5' id='longitude' />
</div>
</div>
<div class="model-footer"></div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
脚本
var map = L.mapbox.map('map', 'examples.map-9ijuk24y')
.setView([0, 0], 2);
// get the form …
Run Code Online (Sandbox Code Playgroud)