I have the image below with multiple classes. On click, I need to get the string "wp-image-1228" (those four numbers will always be different) from all of the classes.
I've got the click down, but I can't seem to get what I need using .match.
<img class="size-post_gal wp-image-1228 aligncenter">
If you are in the jQuery .click() handler and need that ID that follows wp-image-:
var id = $(this).prop('class').match(/wp-image-([0-9]+)/)[1];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With