我正在尝试使用正确的选择器来编写这段代码,但似乎无法使其正常工作。
<ul id="message-list">
<li class="clearfix message success unread">
<a href="/messages/mark_read/61/" class="message-close"></a>
<h4>
<strong>
Getting Real: The Smarter, Faster, Easier Way To Build A Successful Web Application
</strong>
has been added to your profile.
</h4>
<form action="/profile/tweet/NIZNQwAACAAJ/" method="post">
<div style="display:none">
<input type="hidden" value="3b723be17da67c5bc54b27a98a660d53" name="csrfmiddlewaretoken">
</div>
<input type="submit" class="button tweet-button" value="Tweet This Book">
</form>
</li>
</ul>
$('.tweet-button').click(function (e) {
var $list_item = $(this).parent('ul li.message'); < ----- ? ? ?
var $anchor = $(this).parent('a'); // ?? <------
});
我正在尝试获取具有类名为“message”的最上层列表项的选择器和紧邻表单的锚标签。 有什么想法吗?