[英]Python CGI using JQuery fadeIn/fadeOut effect
I'm trying to use the fadeIn effect with jQuery in my python cgi code. 我试图在我的python cgi代码中将fadeIn效果与jQuery一起使用。
But for some reason it isn't working. 但是由于某种原因,它无法正常工作。
My python cgi code: 我的python cgi代码:
#!/usr/bin/python
# Import modules for CGI handling
import cgi, cgitb
# Create instance of FieldStorage
form = cgi.FieldStorage()
# Get data from fields
full_name = form.getvalue('fullname1')
address = form.getvalue('address1')
phone = form.getvalue('phone1')
print "Content-type:text/html\r\n\r\n"
print "<html>"
print "<head>"
print "<title>Python</title>"
print """
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript">
$('#pad').hide().fadeIn(800).delay(3000).fadeOut(800);
</script>
"""
print "</head>"
print "<body id='two'>"
print "<h2>Full Name: %s</h2>" % (full_name)
print "<h2>Address %s</h2>" % (address)
print "<h2 id='pad'>Phone #: %s</h2>" % (phone)
print "</body>"
print "</html>"
I'm trying to fadeIn that third h2 with the id: pad. 我正在尝试使用id:pad在第三个h2中淡入淡出。
This is what I'm using to fadeIn and fadeOut 这就是我用来淡入淡出的东西
$('#pad').hide().fadeIn(800).delay(3000).fadeOut(800);
It doesn't fade in nor fade out. 它不会淡入或淡出。
Many thanks! 非常感谢!
Since your script is placed above #pad
, it is executing before #pad
loads. 由于您的脚本位于
#pad
上方,因此它会在#pad
加载之前执行。 Either place the script at the end of the <body>
or wrap it in $(document).ready()
: 将脚本放在
<body>
的末尾,或将其包装在$(document).ready()
:
$(document).ready(function() {
$('#pad').hide().fadeIn(800).delay(3000).fadeOut(800);
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.