如何獲取打印在console.log中的值,並將它們設置爲輸入字段中的值?從console.log獲取值並在輸入字段中顯示/打印/返回
這裏是的jsfiddle,包含所有我到目前爲止 - https://jsfiddle.net/ubo1heru/
,通過該值被放入的console.log代碼:
$("button").click(function() {
var dishkoMap = {};
$("select[name='diskho'] > option:selected").each(function() {
var value = this.value;
if (dishkoMap[value]) { // if value already exists then increase it by 1
dishkoMap[value] += 1;
} else {
dishkoMap[value] = 1;
}
});
// dishkoMap is a dictionary object so you won't see anything in alert.
// open the browser console and you can see the counts corresponding
// to each selected option
console.log(dishkoMap);
});
爲什麼不創建一個函數,除了在bro wser控制檯,更新輸入字段的值? –
我想弄清楚如何做到這一點 – ChriChri