如何显示/隐藏表单击
How to show/hide table onclick
我试图显示/隐藏表#block-views-apk_user_tracker_page-block_1 .views-table
onclick链接"通知",这是在div #block-views-apk_user_tracker_page-block_1 .views-header
内。我试过不同的脚本,但没有一个工作,他们似乎都是id或列表,而不是类和表。
这是代码,它用于网站通知,facebook风格。
<div class="view-header">
<img src="/photos/led_red.gif"> <a href="/user/3/newforumposts">NOTIFICATIONS (6)</a> </div>
<div class="view-content">
<table class="views-table cols-6">
<thead>
<tr>
<th class="views-field views-field-title">
</th>
<th class="views-field views-field-last-comment-timestamp">
</th>
<th class="views-field views-field-new-comments">
</th>
</tr>
</thead>
<tbody>
<tr class="odd views-row-first">
<td class="views-field views-field-title">
<a href="/node/3955">TITLE 1</a> </td>
<td class="views-field views-field-last-comment-timestamp">
24/05/2015 - 03:56 </td>
<td class="views-field views-field-new-comments">
<a href="/node/3955?page=14#new">1 new</a> </td>
</tr>
<tr class="even">
<td class="views-field views-field-title">
<a href="/node/10452">TITLE 2</a> </td>
<td class="views-field views-field-last-comment-timestamp">
24/05/2015 - 03:24 </td>
<td class="views-field views-field-new-comments">
<a href="/node/10452#new">2 new</a> </td>
</tr>
<tr class="odd">
<td class="views-field views-field-title">
<a href="/node/10445">TITLE 3</a> </td>
<td class="views-field views-field-last-comment-timestamp">
24/05/2015 - 03:21 </td>
<td class="views-field views-field-new-comments">
<a href="/node/10445?page=2#new">1 new</a> </td>
</tr>
<tr class="even">
<td class="views-field views-field-title">
<a href="/node/3871">ANOTHER TITLE</a> </td>
<td class="views-field views-field-last-comment-timestamp">
24/05/2015 - 03:17 </td>
<td class="views-field views-field-new-comments">
<a href="/node/3871?page=8#new">1 new</a> </td>
</tr>
<tr class="odd">
<td class="views-field views-field-title">
<a href="/node/10470">Yet another title</a> </td>
<td class="views-field views-field-last-comment-timestamp">
24/05/2015 - 03:14 </td>
<td class="views-field views-field-new-comments">
<a href="/node/10470#new">1 new</a> </td>
</tr>
<tr class="even views-row-last">
<td class="views-field views-field-title">
<a href="/node/10469">and another</a> </td>
<td class="views-field views-field-last-comment-timestamp">
24/05/2015 - 03:13 </td>
<td class="views-field views-field-new-comments">
<a href="/node/10469?page=1#new">1 new</a> </td>
</tr>
</tbody>
</table>
</div>
不需要再添加id
或class
$(function() {
$(".view-header").click("a", function(e) {
e.preventDefault();
$(".view-header").siblings(".view-content").toggle();
});
});
如果我理解的话,你想在用户点击
时隐藏/显示classview-table
的div您必须为 class
或 id
添加 <a href="/user/3/newforumposts">
,如下所示:
<div class="view view-apk-user-tracker-page view-id-apk_user_tracker_page view-display-id-block_1 view-dom-id-6">
<div class="view-header">
<img src="/photos/led_red.gif">
<a href="/user/3/newforumposts" class="notif isShown">NOTIFICATIONS (6)</a>
</div>
<!-- Following the code -->
你将能够实现你的目标与这个js代码:
$(document).ready(function() {
$('#block-views-apk_user_tracker_page-block_1 .views-header .notif').click(function () {
if($(this).hasClass('isShown')) {
$(this).removeClass('isShown');
$('#block-views-apk_user_tracker_page-block_1 .views-table').fadeOut(250);
} else {
$(this).addClass('isShown');
$('#block-views-apk_user_tracker_page-block_1 .views-table').fadeIn(250);
}
});
});
相关文章:
- 使用javascript取消隐藏和隐藏表单中的某些元素
- 如何使用javascript隐藏表单的选项
- 模拟隐藏表单提交&使用JavaScript重定向以实现安全支付
- 未执行Ajax隐藏表单提交验证
- 在同一个html页面中显示servlet响应而不隐藏表单
- 自动提交隐藏表单值
- 如何筛选出发布的隐藏表单输入类型
- 如何在angularjs中提交后隐藏表单
- 如果用户登录了Backbone,JavaScript,如何显示/隐藏表单
- 显示/隐藏表单区域(im 使用引导程序)
- 如何隐藏表单并仅在选中时显示
- 如何通过隐藏表单在同一页面中显示表单输出
- 如何在同一窗口中显示表单输出并隐藏表单
- 使用 jquery 选择选项时隐藏表单选项
- 当一组元素的所有元素都具有特定值时,如何隐藏表单元素
- 如果禁用了javascript,则隐藏表单
- 选择下拉列表中的值时隐藏表单
- 无法隐藏/取消隐藏表单内的按钮
- 如何根据最后选择的选项(单选按钮)使用 javascript 隐藏表单输入
- 显示和隐藏表单