tags:

views:

36

answers:

2

Hello all! I'm trying to add a blank space in the following.

$('.post_name'+post_id+'').hide();

So it will render something similar to

post_name 8

I tried adding '' and " " but they don;t work. Can someone please help me?

+1  A: 

Use:

$('.post_name ' + post_id)

Result will be like post_name 8

Make sure that your selector works in such format :) Let's know if you have any problems with the selector.

Sarfraz
Thanks for the response! I tried but still no go :( What I'm doing is retrieving the id from a div and passing it to a class name<code>('.edit').click(function(){var cat_id = $(this).attr("id"); //get link ID$('.cat_name ' +cat_id+'').hide();</code>the cat name_name div is for example "Sports 8" and if I could achieve a blank space in the js the class should hide()It works however without blankspaces "Sports8" but I need teh space to style the div name and also have unique numbers
vii
nvm, I'll just put the data in an id and use class to style elements the same :)
vii
A: 

Have you tried:

selector = 'post_name '+post_id;
$(selector).hide();

That might make it a little more extensible.

iamfriendly