sonia
sonia

Reputation: 317

jquery selector for php-generated class

In wordpress, I created a div within the post preview, something like

<div class="postbox">  
<h2><a class="showhide" href="<?php the_permalink(); ?>" rel="<?php the_ID(); ?>"><?php the_title(); ?></a></h2>  
<div class="post-<?php the_ID(); ?>"></div>
</div>

now, I want to make a jquery selector for that inner div.

I have defined

var post_url = $(this).attr("href");
var post_id = $(this).attr("rel");

to accomplish something like

 $(".post-"[post_id]).html("loading...");

but it's not working.

Upvotes: 0

Views: 72

Answers (1)

George Cummins
George Cummins

Reputation: 28926

Your Javascript string concatenation is off. Please try:

$(".post-" + post_url).html("loading...");

Upvotes: 2

Related Questions