JSFiddle - React, Tailwind, and code Playground

HTML

<a href="/post.php?p=100">
    <img src="http://www.placehold.it/100x100" />
</a>

<a href="/post.php?p=660">
    <img src="http://www.placehold.it/100x100" />
</a>

<a href="/post.php?p=32">
    <img src="http://www.placehold.it/100x100" />
</a>

JavaScript

// I want to be able to figure out a way with jQuery, to take the value of 'P' from the parent link (100, 660, 32) and then change the image src from "placehold.it" to "/100.jpg" if at all possible?
$("a img").attr("src", function() {
    var theSrc = new RegExp("[\\?&]p=([^&#]*)").exec($(this).parent()[0].href)[1];
    this.src = theSrc +".jpg";
});