How to add string to jQuery selector?
        Posted  
        
            by Deshiknaves
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Deshiknaves
        
        
        
        Published on 2010-04-27T11:57:09Z
        Indexed on 
            2010/04/27
            12:03 UTC
        
        
        Read the original article
        Hit count: 328
        
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 replaced with a number. In the function I need to call $('show_posts_XXXXXX') - XXXXXX being the generated ID. I have stored this ID in a variable called postId.
But I can't seem to do this $("'" + "show_posts_" + postId + "'")
Can anyone tell me how I can add a string to the end of a selector?
© Stack Overflow or respective owner