Select div using wildcard ID

前端 未结 9 1776
旧时难觅i
旧时难觅i 2020-11-29 11:30

How to select a div using it\'s ID but with a widcard?

If the DIV\'s ID is statusMessage_1098, I would like to select it in some way like document

9条回答
  •  情话喂你
    2020-11-29 11:57

    I'm not sure how you're populating it but if it's from the code behind you could try something like:

    document.getElementById('statusMessage_<%= generatedID %>')
    

    where generatedID is the ID generated from the code behind.

提交回复
热议问题