[英]Is There a More Efficient Way to Alter HTML Text with JavaScript
[英]Alter JavaScript Object to be more Numerical
我想改變這個JS對象。 我目前有:
for(var i = 0; i < destination_categories_selected.length; i++)
{
destination_categories_obj[i] = {
"category" : $(destination_categories_selected[i]).data("dkDropdownValue")
}
}
哪個輸出和對象看起來像
[0] => "category" : 1,
[1] => "category" : 2,
[2] => "category" : 3
我可以這樣做,以便類別完全刪除到類似:
[0] => 1,
[1] => 2,
[2] => 3
如果我已正確理解您的問題,那么只需將值直接分配給相關的destination_categories_obj
元素,而不是將對象分配給它:
for(var i = 0; i < destination_categories_selected.length; i++) {
destination_categories_obj[i] = $(destination_categories_selected[i]).data("dkDropdownValue");
}
for(var i = 0; i < destination_categories_selected.length; i++)
{
destination_categories_obj[i] =
$(destination_categories_selected[i]).data("dkDropdownValue");
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.