I'm using python flask with my site to display content from a database, and I'm trying to make each list item clickable. I've looked at various questions on stackoverflow about how to make a list item clickable, which I can do, but only the first list item in this list is clickable, and the rest do nothing. Can someone please show me what I'm doing wrong? This is my first time doing html/js/jquery stuff so I'm confused.
HTML code:
<ul id="listing-list">
{% for listing in listings %} <!-- For loop puts all results in the columns-->
<li>
<div id="listing">
<input type="hidden" class="id_align" name="id_align" value="{{ listing.id }}">
<div id="name-address">
<div id="listing-name">{{ listing.listing_name }}</div>
<div id="listing-address">{{ listing.address }}</div>
<div id="room-bath">
<span id="listing-rooms">{{ listing.rooms }} bed</span>
·
<span id="listing-bath">{{ listing.bathrooms }} bath</span>
</div>
<div id="listing-comments"><br>Comments: {{ listing.comments }}</div>
</div>
<div id="listing-price">${{ listing.price }}</div>
</div>
</li>
{% endfor %}
</ul>
JQuery code:
$( "#listing" ).click(function() {
var list_id = $( ".id_align" ).val();
//alert(list_id);
var location = "/create_review/" + list_id;
//alert('' + location);
window.location.href = location;
});