I would like to get the number in a class name.
I have this class only once on each page. I need to know what page I'm on when the $(window)
is load.
I can't change the structure
.frm_page_num_xx
I don't get any number in my console. Is my variable correct?
I got : Uncaught TypeError: Cannot read property 'match' of undefined
var pageNum = $('[class^="frm_page_num_"]').attr('class').match(/frm_page_num_(d+)/)[1];
console.log(pageNum);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="frm_page_num_1">
<div class="my-content"></div>
</div>
question from:https://stackoverflow.com/questions/66064047/get-number-in-a-class-name-with-jquery