php中的图像和可见性
Image and visibility in php
我试图在Stack Overflow中找到这个问题,但由于没有找到,我问它:
我正在尝试创建一个程序,该程序有一个包含2列的表。在第一列中,我有一个图像,第二列为空。当我点击图片时,我想在第二列中看到一个URL。
如果我转到第二行并单击图像,那么第一行中的url将消失,第二行的url将出现。这是我的代码,但由于某种原因,我不知道它不工作。如果有人能给出任何评论或任何建议的代码,我将不胜感激:
<table class="table tb-mytable">
<?php if($as_result){?>
<td class="img-parent"><img src="../../uploads/<?=$as_result['as_asset']?>" style="width:<?=$width/2?>px; height:<?=$height/2?>px;" class="<?=$as_result['as_id']?> test" /></td>
<td class="<?=$as_result['as_id']?> iframe-link">
<?php echo htmlentities('<iframe frameborder="0" width="'.$width.'px" height="'.$height.'px" style="overflow:hidden;padding:0px; margin:0px;" scrolling="no" src="'.$site_url.'stream/?q=c_'.(filter_input(INPUT_GET, 'mycamp')).'|p_'.$_SESSION['code'].'|a_'.$as_result['as_id'].'"></iframe> ');?>
</td>
这是JavaScript部分:
$('.img-parent').click(function(){
$(this).next('td').css('visibility', 'visible');
});
这是css:
.iframe-link{
visibility: hidden;
}
这可能对您不起作用,因为在click
函数中,您只更改了包含URL的相邻第二列的visibility
。但是,您首先需要隐藏上次可见的URL。一个解决方案可能是:
$(function() {
//Hide the second column as soon as the document loads
//Although you shouldn't require this since your css already does it
$( "td.iframe-link" ).css('visibility', 'hidden');
//The click functions that toggles the visibility of the adjacent element
$('.img-parent').click(function(){
//Assuming the class for the adjoining td i.e the second column is iframe-link
//Hide all such elements first
$( "td.iframe-link" ).css('visibility', 'hidden');
//Display the relevant element
$(this).next('td').css('visibility', 'visible');
});
});
希望这能让你朝着正确的方向开始。
相关文章:
- D3在一个调用中绘制不同的SVG形状,没有可见性
- jQuery css可见性在load方法中不起作用
- 页面可见性API实际上支持操作系统屏幕锁定吗
- 有没有一种方法可以从隐藏的可见性(CSS,JS)中获得淡入效果
- JavaScript可见性不起作用('隐藏'起作用,'可见'不起作用)
- 从内部回调的可见性
- Openlayers 3为了可见性而绑定到Vector层的复选框没有任何作用
- 在另一个下拉列表中的选择上切换下拉列表中选项的可见性
- 如何禁用mouseout可见性=“;隐藏的“;对小于768px的介质的影响
- 在网格视图的自动刷新过程中,设置内部网格视图文本框的可见性
- 使用javascript的图像可见性
- 如何在 JavaScript 中更改图像可见性
- 隐藏可见性会隐藏图像,但仍会显示隐藏元素占用的空间
- 页面加载时,图像的可见性值是否设置为隐藏
- php中的图像和可见性
- 检查图像文件的可见性
- D3设置图像可见性=隐藏错误
- 将图像可见性设置为假
- 使用cookie/复选框持久化图像可见性
- 我将如何去计时与javascript图像的可见性,例如使用myTimer