I have created one div of id="modal". In this div there is a anchor tag .Inside this tag i am getting data from database .
<div id = "modal">
<a href = "javascript:void(0)" onclick = "document.getElementById('light_<?php echo $mode_id; ?>').style.display='block';document.getElementById('fade_<?php echo $mode_id; ?>').style.display='none'"><button style="border: none;color: inherit;background-color: white; font-size: 13px;"><?php echo $mode_name; ?> : <?php echo $mode_start_time; ?> - <?php echo $mode_end_time; ?>, <?php echo $mode_day_week; ?> </button></a>
</div>
Now, I want that when i clicked on anchor tag in which data is coming from database. it display the another div(id= "light_") of id light_1.and first div (modal) hide.
<div id="light_<?php echo $mode_id; ?>" class="white_content" style = "width: 300px; height: auto;" >
<div id="fade_<?php echo $mode_id; ?>" class="black_overlay"></div>
</div>
This answer requires JQuery.
To hide the #fade_*
div: you can use $(#fade_*).delay(delay).fadeOut();
, where delay is the time it takes to hide (animation).
Apply style: display: none
to the div you want to have hidden at first.
To show the #light_*
div: you can use :
$(#light_*).text('');
$(#light_*).fadeIn("slow").append(message);
where message is the text that will be displayed.
You can create a function to call to make your code readable, like this sample:
<div id="modal">
<a href="javascript:void(0)" onclick="show_func()"> <!--Your Codes--> </a>
</div>
<script>
function show_func(){
$("#modal").hide(); //hide the <div id="modal">
$("#light_1").show(); //show1
//or try this one
document.getElementById("light_1").innerHTML = "Your Codes"; //show2
}
</script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.