我這樣做代碼: index.php文件重定向JQuery的
<html>
<head>
<title>Jeu de dammes</title>
</head>
<style>
form { margin-left:500px;margin-top:300px; width:300px }
</style>
<body>
<form id="formulaire" style="margin-left:100px, padding: 15px" >
<table>
<tr><td><h4> The first player</h4></td>
<td><input type="text" id="premier"></td>
</tr>
<tr><td><h4> The second player</h4></td>
<td><input type="text" id="deuxieme"></td>
</tr>
<tr>
<td></td>
<td>
<button id="action">Play</button></td>
</tr>
</table>
</form>
<script src="jquery-1.5.1.js"></script>
<script>
$(function() {
$('#action').click(function() {
var j1= $('#premier').val();
var j2= $('#deuxieme').val();
if(j1=="") alert('saisir le nom du premier joueur');
if(j2=="") alert('saisir le nom du deuxieme joueur');
if(j2!="" && j1!="") {$(location).attr('href',"http://www.google.com");}
});
$('body').css('background-image', 'url(flower2.jpg)').css('background-size', '100%');
$("#formulaire").css('background-image', 'url(flower.jpg)');
});
</script>
</body>
</html>
我的問題是在事件點擊重定向到「www.google.com」不work.any建議:
- 這個錯誤的原因是什麼?
- 我該如何糾正它?
那麼,沒有警報,沒有重定向?控制檯中有任何日誌? –