Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <% books.forEach(function(book){ %>
- <button onclick="getBookDetails(<%=book %>);" > <%=book.name %></button>
- <% }); %>
- function getBookDetails(book){
- //using book object
- }
- <% books.forEach(function(book){ %>
- <button onclick="getBookDetails(<%-JSON.stringify(book)%>);"><%=book.name %></button>
- <% }); %>
- <% books.forEach(function(book){ %>
- <button onclick="getBookDetails('<%= JSON.stringify(book) %>')"><%= book.name %></button>
- <% }) %>
- function getBookDetails(bookString){
- let book = JSON.parse(bookString)
- // now you can use the book object
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement