0
HTMLjQuery的:抓住的textContent從子元素
<a href="report.php?id=5&file=name.jpg" id="5" class="report">Report Content<span class="hidden">name.jpg</span></a>
jQuery的
$('.report').click(function(event) {
var id = this.id;
var file = $(this).children('span').textContent;
alert(file);
$(this).fadeOut("slow");
$.ajax({
type: 'GET',
data: 'id=' + id + '&file=' + file,
url: 'http://www.sitename.com/report.php',
success: function() {
}
});
return false;
}
的我遇到的麻煩的代碼行:
var file = $(this).children('span').textContent;
如何正確我搶跨度的文本內容並將其存儲在變量中file
?
另外,有沒有更好的方法,我應該這樣做,或者是我的方法好嗎?