I'm trying to pass a dynamic value(ejs) from one page to another. I'm trying to get the value into a variable and the console logging it but nothing happens. Here is my code
<%- include('partials/headerNavbar') %>
<% allMovies.forEach(function(item){ %>
<div class="movie_card">
<div class="main_box">
<!-- var linkToImage = <%=item.wallpaper%> -->
<div class="img_box" style="background-image:url(<%=item.wallpaper%> )">
</div>
<div class="content_box">
<h1> <%=item.title%> </h1>
<h2> <%=item.director%> </h2>
<h3> <%=item.genre%> </h3>
<p> <%=item.desc%> </p>
<button type="button" id="specReview" onclick="myFunction(); location.href='/specificReview';" class="btn btn-outline-warning">Write A Review</button>
<button type="button" class="btn btn-outline-warning">Add To Watchlist</button>
<button type="button" class="btn btn-outline-warning">Watch Trailer</button>
<!-- onclick="location.href='/specificReview'" -->
</div>
</div>
</div>
<script>
function myFunction(){
var name = $("h1").val();
console.log(name);
}
</script>
<% }) %>
<%- include('partials/footer') %>
The script doesn't seem to work. Any help will be appreciated, thanks
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…