0
HTMLからグラブのTextContentjQueryの:子要素
<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
に保存しますか?
また、私はこれを行うべきであるか、私の方法でいいですか?