2017-08-12 82 views
0

我正在使用bootstrap tagsinput字段。在我使用jquery下面添加代碼可以成功工作的項目。bootstrap tagsinput使用jquery刪除項目

$('#tag').tagsinput('add', { "value": 1 , "text": "Amsterdam" , "continent": "Europe" }); 

現在我需要使用jquery刪除添加的項目。我試過以下代碼

$('#tag').tagsinput('remove', { "value": 1 , "text": "Amsterdam" , "continent": "Europe" }); 

但它似乎不工作。如何使用jquery刪除項目。

回答

0

我想你已經這樣做了錯誤,你已經使用:

$('#tag').tagsinput('remove', { "value": 1 , "text": "Amsterdam" , 
"continent": "Europe" }); 

,但我認爲它應該是:

$('#tag').tagsinput('remove', { value: 1 , text: 'Amsterdam' , 
continent: 'Europe' }); 

嘗試做這個,我希望作品。

+1

我想你也必須提及一個特定的標籤ID來刪除它們。 –

+0

我試過了。沒有工作。 ('itemRemoved',function(event){('#typeahead_lang_en')。tagsinput('remove',{value:event.item ['value' ],text:event.item ['text']}); $('#typeahead_lang_ja')。tagsinput('remove',{value:event.item ['value'],text:event.item ['text ']}); })' 但現在它返回thi serror'不能讀取未定義的屬性'值' – Bipin

+0

嘗試在函數內部安慰事情,這可能是一個機會,可能有任何其他錯誤 –