<div></div>
<span></span>
<i class="page-template page page-id-123"><i>
const getPageId = () => $("[class*='page-id-']")
    .attr("class")
    .split(" ")
    .filter(c => /page-id-(\d+)/gm.test(c))
    .map(c => c.split("-").pop()).shift();

console.log(getPageId());

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js