Jquery 没有为 htmlstring 更新 .html()
Jquery not updating .html() for htmlstring
我有一组 html 字符串,想使用我已经构建的插件动态更新字符串的值。
基本上我的插件这样做,当我调用它时,它将规范化数字并使用 $(this).html(newValue)
绑定到 html。但是当我调用插件来处理这个 html 字符串它不绑定值。
这是我的 html 字符串
var htmlData = '<div class="clearfix">';
$.each(data, function(key, value) {
htmlData += '<div class="large-1 infographic-box border_right merged-top pull-left widget-data" >';
$.each(value,function(dKey,dValue){
htmlData += '<span id="'+dKey+'['+ key +']" class="'+dKey+' value widget-data" data-value="'+dValue+'">'+ dValue +'</span>';
})
htmlData += '<span class="headline">'+ monthNames[parseInt(key)-1] +'</span>'+
'</div>';
});
htmlData += '</div>';
$('.transaction-section').html(htmlData);
在此之后我将调用我的插件
$(htmlData).find('.widget-data').each(function(){
var value = $(this).text();
$(this).siPrifixx(value,{
maxDigits: 4,
seperator: true,
decimal: 1,
popUp: true,
});
});
但值保持不变,不是 changing.What 是我的问题 code.Can 有人帮我解决这个问题吗?
在调用插件之前 dValue
有点像 1500000,我在我的插件中将它规范化为 1.5M 并且它将覆盖 html value.But 在这种情况下它不是工作,但我的插件处理数据,而不是使用 $(this).html(newvalue)
附加值。newvalue
是格式化值 1500000 to 1.5M
我正在研究它并找到它。
$.each(data, function(key, value) {
htmlData += '<div class="large-1 infographic-box border_right merged-top pull-left " >';
$.each(value,function(dKey,dValue){
htmlData += '<span id="'+dKey+'['+ key +']" class="'+dKey+' value widget-data" data-value="'+dValue+'" >'+ dValue +'</span>';
});
htmlData += '<span class="headline">'+ monthNames[parseInt(key)-1] +'</span></div>';
});
htmlData += '</div>';
$('.transaction-section').html(htmlData);
$('.widget-data').each(function(){
var value = $(this).data('value');
var index = $(this).attr('id');
$(this).siPrifixx(value,{
maxDigits: 4,
seperator: true,
decimal: 3,
popUp: true,
countUp:index
})
});
感谢每一位帮助过我的人!
我有一组 html 字符串,想使用我已经构建的插件动态更新字符串的值。
基本上我的插件这样做,当我调用它时,它将规范化数字并使用 $(this).html(newValue)
绑定到 html。但是当我调用插件来处理这个 html 字符串它不绑定值。
这是我的 html 字符串
var htmlData = '<div class="clearfix">';
$.each(data, function(key, value) {
htmlData += '<div class="large-1 infographic-box border_right merged-top pull-left widget-data" >';
$.each(value,function(dKey,dValue){
htmlData += '<span id="'+dKey+'['+ key +']" class="'+dKey+' value widget-data" data-value="'+dValue+'">'+ dValue +'</span>';
})
htmlData += '<span class="headline">'+ monthNames[parseInt(key)-1] +'</span>'+
'</div>';
});
htmlData += '</div>';
$('.transaction-section').html(htmlData);
在此之后我将调用我的插件
$(htmlData).find('.widget-data').each(function(){
var value = $(this).text();
$(this).siPrifixx(value,{
maxDigits: 4,
seperator: true,
decimal: 1,
popUp: true,
});
});
但值保持不变,不是 changing.What 是我的问题 code.Can 有人帮我解决这个问题吗?
在调用插件之前 dValue
有点像 1500000,我在我的插件中将它规范化为 1.5M 并且它将覆盖 html value.But 在这种情况下它不是工作,但我的插件处理数据,而不是使用 $(this).html(newvalue)
附加值。newvalue
是格式化值 1500000 to 1.5M
我正在研究它并找到它。
$.each(data, function(key, value) {
htmlData += '<div class="large-1 infographic-box border_right merged-top pull-left " >';
$.each(value,function(dKey,dValue){
htmlData += '<span id="'+dKey+'['+ key +']" class="'+dKey+' value widget-data" data-value="'+dValue+'" >'+ dValue +'</span>';
});
htmlData += '<span class="headline">'+ monthNames[parseInt(key)-1] +'</span></div>';
});
htmlData += '</div>';
$('.transaction-section').html(htmlData);
$('.widget-data').each(function(){
var value = $(this).data('value');
var index = $(this).attr('id');
$(this).siPrifixx(value,{
maxDigits: 4,
seperator: true,
decimal: 3,
popUp: true,
countUp:index
})
});
感谢每一位帮助过我的人!