首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >单击函数的Javascript在一个页面上不起作用

单击函数的Javascript在一个页面上不起作用
EN

Stack Overflow用户
提问于 2012-11-10 05:10:57
回答 2查看 197关注 0票数 0

这里的想法是,每当用户单击图像时,他或她都可以在上面的框中查看该人的信息。它以前是有效的,然后突然停止了。下面是我正在讨论的页面的链接和我的代码。

http://www.team3550.org/team/

代码:

代码语言:javascript
复制
    <script type="text/javascript">
        jQuery(document).ready(function($){
            $('#team_pics img, #team_pics2 img').click(function(){
                $('#team_description').html('<img src="' + $(this).attr('src') + '" />' + $(this).next().html());
            });
        });
    </script>
        <div id="team_description">     
            <h1>Click on a picture below to learn more about a team member</h1>
        </div>
        <div id="team_container">
            <div id="team_pics">
                <img src="<? bloginfo('stylesheet_directory'); ?>/images/pixel_chase.png" width="100px" height="100px" style="padding: 30px;"/>
                <div class="caption"><p class="caption_paragraph"><span class="caption_header"><b>Chase Schweitzer</b></span><br>-Third year in FTC<br>-Designer, builder, webmaster<br>-Interests: programming (HTML, CSS, BASIC, Javascript, etc.), web design, music, writing<br>-Plays the guitar and violin</p></div>
                <img src="<? bloginfo('stylesheet_directory'); ?>/images/pixel_annie.png" width="100px" height="100px" style="padding: 30px;"/>
                <div class="caption"><p class="caption_paragraph"><span class="caption_header"><b>Annie Howard</b></span><br>-Second year in FTC<br>-Designer, builder, writer<br>-Interests: music, writing, history, anthropology<br>-Plays the ukelele, sings</p></div>
                <img src="<? bloginfo('stylesheet_directory'); ?>/images/pixel_tanvi.png" width="100px"height="100px" style="padding: 30px;"/>
                <div class="caption"><p class="caption_paragraph"><span class="caption_header"><b>Tanvi Yenna</b></span><br>-Second year in FTC<br>-Designer, builder, engineering notebook organizer<br>-Interests: designing, music, writing, and acting<br>-Plays the piano, guitar and ukelele; sings</p></div>
                <img src="<? bloginfo('stylesheet_directory'); ?>/images/pixel_jordan.png" width="100px" height="100px" style="padding: 30px;"/>                
                <div class="caption"><p class="caption_paragraph"><span class="caption_header"><b>Jordan Burklund</b></span><br>-Fourth year in FTC, two years in FLL<br>-Designer, builder, programmer<br>-Interests: robotics/mechatronics engineering, aviation, and music<br>-CLAD certified</p></div>              
            </div>
            <div id="team_pics2">                   
                <img src="<? bloginfo('stylesheet_directory'); ?>/images/pixel_saketh.png" width="100px" height="100px" style="padding: 0px 30px;"/>        
                <div class="caption"><p class="caption_paragraph"><span class="caption_header"><b>Saketh Undurty</b></span><br>-Fourth year in FTC, two years in FLL<br>-Designer, builder<br>-Interests: 3D modeling/design, architecture, and music<br>-Plays trumpet in concert band and jazz orchestra</p></div>
                <img src="<? bloginfo('stylesheet_directory'); ?>/images/pixel_daniel.png" width="100px" height="100px" style="padding: 0px 30px;"/>
                <div class="caption"><p class="caption_paragraph"><span class="caption_header"><b>Daniel Miller</b></span><br>-Third year in FTC<br>-Designer, builder, promotions<br>-Interests: architecture, graphic design, music<br>-Viola player, mime, and thespian</p></div>
                <img src="<? bloginfo('stylesheet_directory'); ?>/images/pixel_sidd.png" width="100px" height="100px" style="padding: 0px 30px;"/>
                <div class="caption"><p class="caption_paragraph"><span class="caption_header"><b>Sidd Somayajula</b></span><br>-Third year in FTC<br>-Designer, builder, webmaster<br>-Interests: medicine, math, web design, programming (HTML, CSS, BASIC, Javascript, etc.)<br>-Plays tennis</p></div>
            </div>
        </div>
EN

回答 2

Stack Overflow用户

发布于 2012-11-10 05:15:19

您确实看到202行抛出了一个TypeError,对吗?

代码语言:javascript
复制
var top = $('#blog_right').offset().top - parseFloat($('#blog_right').css('margin-top').replace(/auto/,0));

未捕获的TypeError:无法读取未定义的属性“”top“”

我在这个页面上看不到任何ID为blog_right的元素。

票数 1
EN

Stack Overflow用户

发布于 2012-11-10 05:27:47

jQuery(document).ready(function($){调用时在代码中放置断点甚至不会停止。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13316079

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档