JSFiddle - React, Tailwind, and code Playground

HTML

<div id="specialty_pm_1">specialty_pm_1</div>
<div id="specialty_pm_2">specialty_pm_2</div>
<div id="specialty_pm_3">specialty_pm_3</div>

JavaScript

$("[id^='specialty_pm_']").on("mouseenter",function(){
     var id = $(this).attr('id');
     alert(id.substring(13));
});