這裏的想法是,每當用戶點擊圖像時,他或她可以在上面的框中查看關於該人的信息。它之前有效,然後突然停止。這裏是我正在談論的頁面和我的代碼的鏈接。點擊功能的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>
您的網站似乎還有其他一些問題。檢查控制檯。另外,你不應該使用多個** $(document).ready函數**(我查看了你的網站的源代碼)。 – pmandell
@pmandell爲什麼不出於好奇呢?它是否會傷害任何東西,還是代碼味道? – Yatrix