我刚刚在学习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