Selecting Dynamic ID JQuery [migrated]
- by Vedran Wex Maricevic
I need to select dynamic id using JQuery, and once I select it then I need to do some action on it. This is the HTML that I have:
<input id="content_photos_attributes_1355755712119_image" name="content[photos_attributes][1355755712119][image]" size="30" type="file">
Please note the id value, text is always the same however the number changes (I do not have control over that change).
What I need to do is to create on click for that element. This is what I got so far, and it is not working.
<script type="text/javascript">
jQuery.noConflict();
jQuery("input[id *= 'content_photos_attributes_']").click(function() {
alert("Image deletion is clicked");
});
</script>
It really makes no difference whether I select that element by ID or by its name.