【发布时间】:2015-12-02 13:12:53
【问题描述】:
我有一个 jQuery ajax get,它将返回一个 html 文本。我需要从中提取 h3 元素(id='title')值:THIS IS TITLE。
我可以用 jQuery 实现吗?
<div class="content">
<h3 id="title">THIS IS TITLE</h3>
.....
</div>
这是电话:
$.ajax({
url: url,
type: 'GET',
cache:false,
success: function (data) { // data is the html text returned
alert('The title is: ' + TITLE HERE);
}
});
【问题讨论】:
-
也许使用 find 我猜?
-
$(data).find('#title').text() -
由于Id是唯一的,可以使用$('#title').text()