当文本框控件为空时,我需要fadeOut
在文本框控件旁边显示 5 秒钟的消息。请告诉我如何实现这一目标。
<?php
echo "<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js'></script>";
echo "<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.cycle.all.js'></script>";
include_once('db_con.php');
$error = array("txt_categoryErr" => "","txt_brandErr" => "");
echo "<script>
$(document).ready(function(){
$('#sub').click(function(){ $('#toFade').delay(1000).fadeOut(3000); });
</script>
if(isset($_POST['submit'])){
$catq = $_POST['txtName'];
if($catq!=''){
$query = "INSERT INTO `categories`(`id`, `parent_id`, `name`) VALUES ('','','$catq')";
}else{
$error["txt_categoryErr"]="Please enter a valid category name";
}
?>
<div class="txtCategory">
Category Name: <input type="text" id="txt_name" name="txtName" size="12" maxlength="20">
<input type="submit" class="btnsub" id="sub" name="submit" value="Add">
<div id="toFade"><small name="Errtxt" class="errorText"><?php echo $error['txt_categoryErr']; ?></small></div>
</div>