2014-03-05 52 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