我剛剛在學習jQuery,想知道是否有可能讓我的代碼有效的方法?當我點擊綠色按鈕時,它不顯示第二個表格行。我能做些什麼來避免將來出現這種錯誤?我願意接受任何幫助!謝謝,麻煩您了。jQuery:按鈕切換沒有按預期運行
的jQuery:
$(document).ready(function() {
$("button").click(function() {
$(".row2").show();
});
});
HTML:
<table>
<tr class="row1">
<td>
<p>This is where the text in the boxes will go!</p>
</td>
<td>
<p>This is where the text in the boxes will go!</p>
</td>
<td>
<p>This is where the text in the boxes will go!</p>
</td>
<tr class="row2">
<td>
<p>This is where the text in the boxes will go!</p>
</td>
<td>
<p>This is where the text in the boxes will go!</p>
</td>
<td>
<p>This is where the text in the boxes will go!</p>
</td>
</tr>
</table>
<a class="greenbuttontext" href="#"><button class="showmorebutton">Show9 more concepts</button></a>
CSS:
/*styles for green showmore button*/
.showmorebutton {
height: 33px;
border: solid #628b06 1px;
border-radius: 5px;
width: 200px;
margin-left: 600px;
margin-bottom: 25px;
text-align: center;
background-color: #99cd00;
color: white;
vertical-align: center;
line-height: 33px;
}
.greenbuttontext {
text-decoration: none;
}
/*row2 disappear*/
.row2 {
display:none;
}
工作正常http://jsfiddle.net/uk3E3/9/。可能你沒有在你的代碼中引用jquery –
控制檯中的任何錯誤?你至少正確地包括jQuery? –
我最終一起去除了錨標籤,它工作。謝謝! – user3795395