i'm still learning to become a junior front end and got following issue if i press search button it breaks the page can figure out why. https://codepen.io/DeanWinchester88/pen/ExvxdxX
Could you have a look?
function searchPokemon(){
let container = document.getElementById("container");
container.insertAdjacentHTML("beforeend",`<div id="searchPokemonDiv"> ИТуц ыуфкс</div>`);
let gotSearchPokemonDiv = document.getElementById("searchPokemonDiv");
gotSearchPokemonDiv.innerHTML = `<form >
<p>
<label class="text">Search your pokemon</label><br>
</p>
<p>
<label class="text">First name</label><br>
<input type="text" name="name">
</p>
<p>
<button id="pokemonSearchButton">Search</button>
</p>
</form>
<div id="divForPokemonSearchResult">
img
</div>
`;
document.getElementById("pokemonSearchButton").addEventListener("click", showPokemonSearchResult);
}
function showPokemonSearchResult(){
// document.getElementById("divForPokemonSearchResult").innerHTML = "VOT I RESULTAT";
console.log("push to start")
}
The bug was in this line:
<button id="pokemonSearchButton">Search</button>
and it was fixed by adding type="button" to the same, i.e.
<button type="button" id="pokemonSearchButton">Search</button>