好的,我无法让这个 jQuery 工作!它是如此简单!我想要它做的就是让#main div 在加载时淡入淡出。
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="randomizer.js"></script>
<title>
<?php
if (isset($_POST['first']) && isset($_POST['second'])) {
echo "Randomized {$_POST['first']}-{$_POST['second']}";
}
else {
echo "Randomizer";
}
?>
</title>
<link type="text/css" rel="stylesheet" href="randomizer.css" />
<script type="text/javascript" src="randomizer.js"></script>
</head>
<body>
<?php
if (isset($_POST['first']) && isset($_POST['second'])) {
$grabFirst = strip_tags($_POST['first']);
$grabSecond = strip_tags($_POST['second']);
}
?>
<div id="main">
<center><form action="randomizer.php" method="post">
<input type="text" name="first" value="<?php if(isset($grabFirst)){ echo htmlspecialchars($grabFirst); } ?>" placeholder="First Number" /><br />
<input type="text" name="second" value="<?php if(isset($grabSecond)){ echo htmlspecialchars($grabSecond); } ?>" placeholder="Second Number" /><br />
<input type="submit" />
</form>
<?php
if (isset($_POST['first']) && isset($_POST['second'])) {
$grabFirst = strip_tags($_POST['first']);
$grabSecond = strip_tags($_POST['second']);
}
else {
print "Please enter two numbers.\n";
die;
}
if (strlen($grabFirst) < 1 or strlen($grabSecond) < 1) {
print "Please make sure you filled out both feilds.\n";
die;
}
elseif (!is_numeric($grabFirst) && !is_numeric($grabSecond)) {
print "Please make sure you entered two valid numbers.\n";
die;
}
elseif (!is_numeric($grabSecond)) {
print "Please make sure you entered two valid numbers.\n";
die;
}
elseif (!is_numeric($grabFirst)) {
print "Please make sure you entered two valid numbers.\n";
die;
}
else {
}
$rand = rand($grabFirst, $grabSecond);
print "A random number between {$grabFirst} and {$grabSecond} is {$rand}.\n";
?></center>
</div>
</body>
</html>
这是我的 jQuery
$(document).ready(function(){
$('#main').fadeTo('slow', 1);
});
如果有人可以提供帮助,我将不胜感激。我一直在尝试修复它一个小时,但我没有运气。我刚开始使用 jQuery 并且没有经验,也许这是一个非常愚蠢的错误,但我不知道。谢谢~