我正在嘗試使用Wordpress的「回覆」按鈕進行評論,並使其獲取您正在回覆的評論的用戶名,並將其發佈到評論textarea框中@USERNAME
當一個鏈接被點擊時,獲取另一個類的內容
下面是我的Wordpress評論的輸出。第6行的存在,有一個類名url
一個鏈接,鏈接文本是jasondavis
下越往下第15行存在的回覆鏈接,它具有類的comment-reply-link
當用戶點擊該回復鏈接,我想在這種情況下獲得用戶名jasondavis
,所以我可以稍後將其插入到textarea框中。
我認爲這是可以使用jQuery來完成,假設有多個被點擊的回覆鏈接,所以當頁面上這些評論的,它必須足夠聰明,從.url
得到文本,但只能從直接.url
在該答覆按鈕/鏈接被點擊的特定評論的回覆按鈕之前。
如果您有任何建議或可以幫助我將不勝感激
<li class="comment byuser comment-author-jasondavis bypostauthor even depth-2" id="comment-6">
<div class="c-grav"><img alt="" src="http://1.gravatar.com/" class="avatar avatar-60 photo" height="60" width="60"></div>
<div class="c-arrow"></div>
<div class="c-body">
<div class="c-head">
<a href="http://www.codedevelopr.com/" rel="external nofollow" class="url">jasondavis</a>
<span class="c-date">December 30, 2011 8:00pm</span>
</div>
<p>Comment body text is here......</p>
<span class="edit-comment">
<a class="comment-edit-link" href="" title="Edit comment">Edit</a>
<a href="">Delete</a>
<a href="">Spam</a>
<a class="comment-reply-link" href="/codedevelopr/php-database-class/?replytocom=6#respond" onclick="return addComment.moveForm("comment-6", "6", "respond", "5")">Reply</a>
</span>
</div><!--end c-body-->
</li>
這是真棒它讓我看到它是可行的,我將與它的一些玩,但它是在正確的軌道上,以便謝謝!我遇到的問題是我也有線索評論,所以如果評論有5個回覆,我點擊主評論上的回覆按鈕,它將顯示所有5條評論中的長名字,如果只有1條評論我也在回覆,然後顯示的只是1個名字,所以只需要找出扭曲的結果 – JasonDavis 2012-01-07 08:02:05
@jasondavis:你應該可以在添加'.first()'或'.last()'之後'.find('。url')'停止解決這個問題。 – icktoofay 2012-01-07 22:45:13