Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私は標準ループを持っています:
<article class="somepost"> <?php $a = get_the_title(); echo $a; ?> </article>
記事をクリックしたときに、投稿のタイトルの価値を取得する方法(class = "somepost")
$('.somempost').click(function(){ ??? });
ありがとう。
まず、タイトルを記事データ属性に設定します。
<?php $a = get_the_title(); ?> <article class="somepost" data-title="<?php echo $a; ?>"> <?php echo $a; ?> </article>
次に、jQueryで、タイトルを次のような変数に設定します。
$('.somepost').click(function(){ var the_title = $(this).data('title'); });