javascript - Image and visibility in php -
i tried finding question in stack overflow since didn't find asking it:
i trying create programme has table 2 columns. in first column have image , sec column empty. when click on image want see url in sec column.
and if go sec row , click image url in first row dissapears , sec row url appear. here code due reason not know not working. appreciate if give comments or suggested code:
<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>
here javascript part:
$('.img-parent').click(function(){ $(this).next('td').css('visibility', 'visible'); });
and here css:
.iframe-link{ visibility: hidden; }
it's not working because in click
function, alter visibility
of adjoining sec column contains url. first need hide url lastly visible. 1 work around be:
$(function() { //hide sec column document loads //although shouldn't require since css $( "td.iframe-link" ).css('visibility', 'hidden'); //the click functions toggles visibility of adjacent element $('.img-parent').click(function(){ //assuming class adjoining td i.e sec column iframe-link //hide such elements first $( "td.iframe-link" ).css('visibility', 'hidden'); //display relevant element $(this).next('td').css('visibility', 'visible'); }); });
hope gets started in right direction.
javascript php css
No comments:
Post a Comment