Get part of a string using jQuery

后端 未结 3 1724
孤独总比滥情好
孤独总比滥情好 2021-02-03 12:20

HTML code:

How can I get number \"45\" of string using jQuery?

3条回答
  •  梦谈多话
    2021-02-03 12:45

    Using jQuery, simply:

    $("[id='block-id-45']").attr("id").split("-")[2]
    

    For all block-id-##, you can use mask pattern from Peter's answer:

    $("[id^='block-id-']").click(function(){
    
        row_id = $(this).attr("id").split("-")[2];
        .............
        .............
    })
    

提交回复
热议问题