html实时显示log,.html返回undefined,但console.log正确显示元素

我有一个jQuery脚本,可以正确地从数据库中获取结果,然后以不同的跨度显示值。

我简化了HTML,这里是jQuery。

$(function(){

$("#userTagsContainer").on('click',function(){

$.ajax({

type: 'GET',

url: 'tags.php',

dataType: 'json',

success: function(response){

response = JSON.stringify(response);

response = response.replace(/"/g,'');

response = response.replace('[','');

response = response.replace(']','');

var tags = response.split(',');

if($('#exist-tags').text().length == 0){

for(var i=0;i

$("#exist-tags").append('');

$('#tag'+i).html(tags[i]);

}

}

},

error: function(xhr) {

alert("FAIL: "+xhr.status);

}

});

});

$("#exist-tags").on('click',function(e){

if(e.target!=this){

console.log(e.target);

var clicked = (e.target).html;

console.log(clicked);

$("#userTagsContainer").append(''+clicked);

}

});

});

在最后一部分中,我有一个包含漂亮css框中跨度的div。如果你单击其中一个跨度,它应该将其名称插入一个可编辑的div(想想hashtags)。

但是,即使console.log正确显示完整元素(包括text / html),.html方法也会返回undefined。任何想法?

编辑:如果你有一个更好的方法来获取和剥离结果,以便向用户提供纯文本,请告诉我。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值