我有一个jQuery ajax get会返回一个html文本.从这一个我需要提取h3元素(id ='title')值:THIS IS TITLE.
我可以用jQuery实现这个目标吗?
<div class="content">
<h3 id="title">THIS IS TITLE</h3>
.....
</div>
Run Code Online (Sandbox Code Playgroud)
这是电话:
$.ajax({
url: url,
type: 'GET',
cache:false,
success: function (data) { // data is the html text returned
alert('The title is: ' + TITLE HERE);
}
});
Run Code Online (Sandbox Code Playgroud)
使用find()方法获取如下所示的值,
$(data).find('#title').text()
Run Code Online (Sandbox Code Playgroud)
如何使用find的示例在这里如何使用find()