52,797
社区成员
发帖
与我相关
我的任务
分享
$(function(){
$("#bbb").click(function(){
$.ajax({
type: 'post',
dataType: 'html',
url: 'xxxxx指定网址123.html',
cache: false,
async: true,
success: function(data){
var $data = $(data) //文档转化为jquery对象
var div = $data.find("[href$='.jpg']");
$("#ceshi").append(div);
}
})
})
})
<a target="_blank" href="http//xxxxxxxxxxx.html?http//xxxxxxxx.jpg">
<img class="picact" border="0" alt="图片alt" src="http//xxxxxxxx.jpg"></a>
$("a[href*='.shtml?http'").map(functon(){
return this.href.replace(/^.*\.shtml\?(.*)$/i,"$1");
}).get().join('')
$("#result").each(function(){
var href=$("a[href*='.shtml?http'").attr("href").replace(/^.*\.shtml\?(.*)$/i,"$1");
console.log(href);遍历后输出为什么只有一条?
返回结果是有4条的。
以下是代码
$.ajax({
type: 'post',
dataType: 'html',
url: 'http//',
async: true,
success: function(data){
var $data = $(data)
var target_div = $data.find("p [href]");
$("#result").append(target_div);
$("[href]").addClass("intro");
$("#result").each(function(){
var href=$("a[href*='.shtml?http'").attr("href").replace(/^.*\.shtml\?(.*)$/i,"$1");
console.log(href);
})