hey I'm currently having a problem on manipulating my div's, see i have this code here that displays a div search result like the ones in google. inside it is another div "overlay" hidden with a "position:fixed;" style and it only displays when the user clicks on the hyperlink Abstract then it will be hidden again once they clicked the overlay div
Problem : once i click on the abstract div, it will return to the state hidden
<div class="SearchResults">';
echo " <span class='top'>";
echo " <a href='#'>";
echo " <h3>". $title ."</h3>";
echo " </a>";
echo " <br />";
echo " <h5 class='sub'>";
echo $abstract;
echo " </h5>";
echo " </span>";
echo " <span class='bottom'>";
echo " <span class='bottomLeft'>";
echo " <a href='#' class='options' onclick='showOverlay(". $run['id'] .")'>";
echo " Abstract";
echo " </a>";
echo " <span style='margin:0px 5px;'>|</span>";
echo " <a target='_blank' href='view.php?filename=NKTI Proceedings vol. 1 no. 1 Feb. 1996' class='options'>";
echo " Full Article";
echo " </a>";
echo " </span>";
echo " <div class='overlay' id='". $run['id'] ."' onclick='hideOverlay(". $run['id'] .")'> ";
echo " <div class='abstract'>";
echo " <h1>".$title."</h1><br /><br /><br />";
echo $run['abstract'];
echo " </div>";
echo " </div>";
echo " <span class='bottomRight'>";
echo " <p class='label'>volume 1, January - April 2015</p>";
echo " </span>";
echo " </span>";
echo " <br style='clear:both;'/>";
echo "</div>";
here's my css code
.abstract
{
z-index:300;
box-shadow:0px 0px 20px rgba(0,0,0,0.5);
padding:20px;
margin:5% auto;
height:500px;
width:80%;
background:white;
overflow:auto;
overflow-wrap:break-word;
text-align:justify;
-webkit-transition:1s;
line-height:1.5;
}
.overlay
{
-webkit-transition:1s;
display:none;
opacity:0;
width:100%;
height:100vh;
background:rgba(0,0,0,0.7);
position:fixed;
top:0px;
left:0px;
z-index:200;
}
and also my javascript code
function showOverlay(id)
{
document.getElementById(id).style['display'] = "block";
document.getElementById(id).style['opacity'] = "1";
}
function hideOverlay(id)
{
document.getElementById(id).style['opacity'] = "0";
document.getElementById(id).style['display'] = "none";
}
note: i just want to achieve the effect like facebook makes when you click an image on the news feed.
onclick='hideOverlay(...)'). PS you can doonclick='showOverlay(this)'then in the functionfunction hideOverlay(element)and element will reference the element so you can then doelement.style.opacity = ...and so on. No passing ID. ;-)