내 사이트에 jQuery Hover effect을 추가하려고합니다. jQuery를 다운로드하는 대신 jQuery 용 Google Libraries API를 사용하기로 결정했습니다. 키가 있고 헤더로가는 코드를 복사 한 다음 호버 효과를 위해 jQuery를 복사했지만 아무것도 성공하지 못합니다. 내가 도대체 뭘 잘못하고있는 겁니까? DOM을 당신이 핸들러를 연결하려는 시점에 아직 존재하지 않는, 그래서Google App Engine에서 Google Libraries API (jQuery)를 사용하는 방법은 무엇입니까?
class JQueryTest(webapp.RequestHandler):
def get(self):
self.response.out.write("""<html>""")
self.response.out.write("""<head>""")
self.response.out.write("""<script type="text/javascript" src="https://www.google.com/jsapi?key=GOOGLE LIBRARIES API KEY"></script>""")
self.response.out.write("""<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js">
$("ul.thumb li").hover(function() {
$(this).css({'z-index' : '10'}); /*Add a higher z-index value so this image stays on top*/
$(this).find('img').addClass("hover").stop() /* Add class of "hover", then stop animation queue buildup*/
.animate({
marginTop: '-110px', /* The next 4 lines will vertically align this image */
marginLeft: '-110px',
top: '50%',
left: '50%',
width: '174px', /* Set new width */
height: '174px', /* Set new height */
padding: '20px'
}, 200); /* this value of "200" is the speed of how fast/slow this hover animates */
} , function() {
$(this).css({'z-index' : '0'}); /* Set z-index back to 0 */
$(this).find('img').removeClass("hover").stop() /* Remove the "hover" class , then stop animation queue buildup*/
.animate({
marginTop: '0', /* Set alignment back to default */
marginLeft: '0',
top: '0',
left: '0',
width: '100px', /* Set width back to default */
height: '100px', /* Set height back to default */
padding: '5px'
}, 400);
});
</script>""")
self.response.out.write("""<link type="text/css" rel="stylesheet"
href="/stylesheets/jquery.css" /> """)
self.response.out.write("""<title>JQuery Test</title>""")
self.response.out.write("</head>")
self.response.out.write("""<body>""")
self.response.out.write("""<div class="content">""")
self.response.out.write("""
<ul class="thumb">
<li><a href="#"><img src="http://ting-1.appspot.com/image?img_id=agZ0aW5nLTFyEAsSCEhvbWVQYWdlGIfcCww" alt="" /></a></li>
<li><a href="#"><img src="http://ting-1.appspot.com/image?img_id=agZ0aW5nLTFyEAsSCEhvbWVQYWdlGIyGCww" alt="" /></a></li>
<li><a href="#"><img src="http://ting-1.appspot.com/image?img_id=agZ0aW5nLTFyEAsSCEhvbWVQYWdlGIm1Cww" alt="" /></a></li>
<li><a href="#"><img src="http://ting-1.appspot.com/image?img_id=agZ0aW5nLTFyEAsSCEhvbWVQYWdlGM-dCww" alt="" /></a></li>
<li><a href="#"><img src="http://ting-1.appspot.com/image?img_id=agZ0aW5nLTFyEAsSCEhvbWVQYWdlGM6dCww" alt="" /></a></li>
<li><a href="#"><img src="http://ting-1.appspot.com/image?img_id=agZ0aW5nLTFyEAsSCEhvbWVQYWdlGIuGCww" alt="" /></a></li>
<li><a href="#"><img src="http://ting-1.appspot.com/image?img_id=agZ0aW5nLTFyEAsSCEhvbWVQYWdlGLrzCww" alt="" /></a></li>
<li><a href="#"><img src="http://ting-1.appspot.com/image?img_id=agZ0aW5nLTFyEAsSCEhvbWVQYWdlGLWlCww" alt="" /></a></li>
<li><a href="#"><img src="http://ting-1.appspot.com/image?img_id=agZ0aW5nLTFyEAsSCEhvbWVQYWdlGLWlCww" alt="" /></a></li>
</ul>""")
self.response.out.write("""</div>""")
self.response.out.write("</body></html>")
jQuery를이 페이지에 잘로드, 문제가 jQuery 코드에 있도록 구글의 jQuery API 또는 구글 AppEngine에 대해 아무것도하지 . Javascript를 디버그하려고 할 때 일반적으로 브라우저에 제공되는 것에 집중하여 백 엔드 코드를 살펴 보는 것이 일반적으로 도움이되지 않습니다. – nrabinowitz
비록 ... jsFiddle에서 코드가 잘 실행되기 때문에 너무 빨리 말할 수도 있습니다. http://jsfiddle.net/nrabinowitz/gdsxH/ – nrabinowitz
이것은 App Engine과 아무 관련이 없습니다. –