jquery ajax只从其他页面获取一个div块
我有一个成功的ajax请求,可以下载整个HTML内容,现在我只需要得到一个包含id“data-today”的div标签。
如何编写这样的脚本?
看看这个SOQ:
- 在jQuery中提取Ajax返回数据
这些方面的东西:
success: function(data) { //create jquery object from the response html var $response=$(data); //query the jq object for the values var dataToday = $response.find('#data-today').text(); }
$('#data-today').html()
如果你想要所有的html //这个输出
如果你想要里面的文字
$('#data-today').text() // this gives hello how are you
.text()在html之间给出了文本
hello how are you