You need .filter()
$("p").html($("#gallery_imgs img").filter("[src='"+that.attr("src")+"']").length);
you can use .find() this way
$("p").html($("#gallery_imgs").find("img [src='"+that.attr("src")+"']").length);
Problem
$("#gallery_imgs img").find("[src='"+that.attr("src")+"']")
you are trying to find the element with src
inside the img
element not within in the img
element