我有一個變量被設置爲一個<div />
jQuery的 - 顯示變量,而不是文本字符串
的.html();
變量是另一個變量的名稱。我希望它顯示其他變量的內容,但它只是顯示其他變量的名稱。
我該如何強制它顯示變量內容而不是文本字符串?
var clothing = 'dogeshop cryptoshop doge_clothing fyrstikken the_molly_machine peace_and_love moolah_market shibe_swag undieguys urban_graff kravshop got_doge mean_elephant the_dogedoor_store';
setInterval(function() {
var term = $("input").val();
$("#results").html(term);
}, 100);
當用戶鍵入「服裝」到$("input");
的「服裝」變量的內容應在$("#results");
<div />
被顯示。相反,它只是說'衣服'。
我不認爲這是正確的機制。爲什麼不使用關聯數組而不是變量?所以你可以查看字符串''''(從'$(「input」)。val()')獲得並檢索''dogeshop cryptoshop ...'')? – lurker