我有一个包含2列的表格。一列是数据,第二列是上/下箭头。
向上箭头不应显示在第一行,向下箭头不应显示在最后一行。我试了很久但没有任何反应。调用该函数但始终显示箭头。 有人可以帮忙吗?
function reset_updown_mbp()
{
$('tr > td > img[src="up.png"]').css('visibility', 'visible');
$('tr > td > img[src="up.png"]:first').css('visibility', 'hidden');
$('tr > td > img[src="dn.png"]').css('visibility', 'visible');
$('tr > td > img[src="dn.png"]:last').css('visibility', 'hidden');
}
答案 0 :(得分:1)
尝试在表格中添加id
,以获取示例:
<table id="myTable">
...
</table>
您的javascript,请尝试使用.hide()
和.show()
函数:
<script>
function reset_updown_mbp()
{
$('#myTable img[src*="up.png"]').show();
$('#myTable img[src*="up.png"]:first').hide();
$('#myTable img[src*="dn.png"]').show()
$('#myTable img[src*="dn.png"]:last').hide();
}
// and remember to call the function
$(document).ready(function() {
reset_updown_mbp();
});
</script>
在jquery过滤器中,我不确定您的html代码是怎样的,因此我使用*=
,因为它Selects elements that have the specified attribute with a value containing the a given substring.
答案 1 :(得分:0)
您是否在reset_updown_mbp
上执行了document.ready
方法?