【发布时间】:2014-07-02 12:54:26
【问题描述】:
我现在正在学习 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;
}
【问题讨论】:
-
工作正常jsfiddle.net/uk3E3/9。可能你没有在代码中引用 jquery
-
控制台有错误吗?你是否至少正确地包含了 jQuery???
-
我最终一起删除了锚标记,并且它起作用了。谢谢!
标签: jquery html css button toggle