Reputation: 13
I have a standart loop with:
<article class="somepost">
<?php $a = get_the_title(); echo $a; ?>
</article>
How I get value of some post's title, when I click on some article (class="somepost")
$('.somempost').click(function(){ ??? });
Thanx.
Upvotes: 1
Views: 473
Reputation: 1534
First, I would set the title to the articles data attribute:
<?php $a = get_the_title(); ?>
<article class="somepost" data-title="<?php echo $a; ?>">
<?php echo $a; ?>
</article>
Then in your jQuery, set the title to a variable like so:
$('.somepost').click(function(){
var the_title = $(this).data('title');
});
Upvotes: 1