How to add string to jQuery selector?

后端 未结 4 1758
半阙折子戏
半阙折子戏 2020-12-19 06:02

I\'m trying to select an id that changes on different posts of same page. So the they have been given an id=\"show_posts_{PostID}\" - on the final output the {PostID} is re

4条回答
  •  情深已故
    2020-12-19 06:14

    You need to include the '#' character at the start of the string.

    $('#show_posts_' + postId)
    

    Also, you're trying to stuff the quotes in there in your example, and that doesn't make sense.

提交回复
热议问题