我有一些代码在单击提交按钮时执行。该代码适用于桌面,但不适用于移动设备。不确定是什么导致了这个问题。
$(document).ready(function(){
emailSubmitButton.click(function(e){
e.preventDefault();
var inputWidth = emailNameInput.width(),
submitWidth = emailSubmitButton.width(),
submitTotal = inputWidth + submitWidth + 38,
userEmail = emailNameInput.val(),
windowWidth = $(window).width();
var errorMessage = function(error){
emailError.html(error);
if (windowWidth > 501) {
emailError.css({opacity: '1', display: 'block', width: submitTotal});
}
else {
emailError.css({opacity : '1', display : 'block', width : '96%', marginLeft : '2%'})
}
};
if(!userEmail){
errorMessage('Please enter your email');
}
else{
if(userEmail == "Enter email..."){
errorMessage('Please enter your email');
}
else
{
if (/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(userEmail))
{
$.ajax({
url: "emailSubmit.php",
type: "GET",
dataType: "json",
data: {type: "emailSubmit", email: userEmail},
success: function (response) {
JSON.stringify(response);
},
error: function (err) {
JSON.stringify(err);
},
complete : function() {
//$('.user-accept').addClass('unhide');
$('.at-wrapper').animate({
opacity : 0
}, 2000)
}
});
$('.user-accept').css({width : submitTotal});
} else {
errorMessage('Invalid email, please try again');
console.log(userEmail);
}
}
}
});
})
关于问题可能是什么的任何想法?移动设备上有什么不同的行为吗?