I'm trying to show an iframe only when I click a button using javascript, but it's not working and I have no idea why.
//I tried this way. did not work.
document.querySelector(".buttonweek").addEventListener('click', function() {ThisWeek();});
function ThisWeek(){
document.querySelector("#week").style.display = "block";
}
//then I tried that way. did not work.
document.getElementById("idweek").addEventListener('click', function() {ThisWeek();});
function ThisWeek(){
document.getElementById("week").style.display = "block";
}
iframe{
display:none;
width: 1280px;
height: 1000px;
}
<ul>
<li><button type="button" class="buttonweek" id="idweek">Hot This Week</button></li>
<iframe src="thisweek.php" id="week"></iframe>
</ul>
I also tried to use the onclick in the obstrusive way, it also did not work !!
If anyone has read this, thank you!