When clicking on an element, I am attempting to hide that specific element. However, all elements share the same id and I need each one to hide individually upon click.
Typically, I would use PHP in a foreach loop to add an incremental value to each ID. Unfortunately, this is not possible in this case.
This is my current setup:
<div id="container">
<a href="#" class="hideme">hide me</a>
SOME TEXT
</div>
<div id="container">
<a href="#" class="hideme">hide me</a>
SOME TEXT
</div>
<script type="text/javascript">
$(".hideme").click(function(){
$(this).hide();
});
</script>
Is there a way in jQuery to hide only the element being clicked? Currently, my code hides only the first element.
Example: https://jsfiddle.net/2rnw224b/