Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
190 views
Welcome To Ask or Share your Answers For Others

1 Answer

Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...