2014-03-05 54 views
0

我输入字段如何清除数据占位符值?

<span class="total_round_size inline-notoolbar-editable" data-placeholder="000,000">{{ deal.total_round_size|intcomma|safe }}</span> 

当我改变另一个输入,数据被复制到这一点,但原文(“000000”)仍然存在,新的文字重叠。如何删除它?我尝试了几种方法,但没有任何效果:

$('.total_round_size').attr('showing-placeholder', ''); 
    $('.total_round_size').innerHTML = ""; 
    $('.total_round_size').text(""); 
    $('.total_round_size').html() = ""; 
    $('input[name=total_round_size]').val(""); 

不希望更改跨度的结构(例如不添加元素)。

编辑: 更多细节

function parse(elem_name) { 
    return parseInt($(elem_name).html().replace(/[\.,,]/g,'')); 
} 
$('#target').change(function() { 
    $('.total_round_size').text(parse('.target')); 
}); 

<div class="row"> 
    <div class="col-md-12"> 
     <div class="pull-left">{% trans "Total Round Size" %}:</div> 
     <div class="pull-left">&nbsp;€&nbsp;<span class="total_round_size inline-notoolbar-editable" data-placeholder="000,000">{{ deal.total_round_size|intcomma|safe }}{% if not deal.total_round_size %}<br/>{% endif %}</span></div> 
    </div> 
</div> 

目标是基本相同的。

回答

0

尝试改变showing-placeholderdata-placeholder这里:

$('.total_round_size').attr('data-placeholder',''); 

因为你已经分配价值data-placeholder属性,而不是showing-placeholder

+1

为什么downvote?这工作。 – DSblizzard

0

试试这个它的工作好:

$('.total_round_size').removeAttr('data-placeholder'); 

$('.total_round_size').attr('data-placeholder',''); 
+0

我很确定第二个不起作用。 – ThiefMaster

0

试试这个

$('.total_round_size').attr('data-placeholder', ''); 
+0

下来投票背后的原因是什么。 – GP12