Event click not working. can you solve it for me

Viewed 61

How to delete an element when I click it

HTML

<span id="portoDeleteFIle_${id}" class="deleteFile" title="Delete">+</span>

//${id} is number and < 99

JS

<script type="text/javascript">
jQuery("span[id^='portoDeleteFIle_']").click(function(e) {
      id = e.currentTarget.attributes.id.value.replace("portoDeleteFIle_", "");
      console.log(id);
});
</script>
1 Answers

Try this:

jQuery("span[id^='portoDeleteFIle_']").click(function(e) {
      id = e.currentTarget.attributes.id.value.replace("portoDeleteFIle_", "");
      console.log(id);
});

There was missing ) in your code.

Related