1

問題は、キー変数と値変数の両方がオブジェクトとして設定されていることです。これらをテキスト文字列に変換するにはどうすればよいですか?

units = [];

$('thead th[style*="width:130px;line-height:1.2em;text-align:center"]').each(function() {

    key  = $(this).contents('')[4];
    value = $(this).contents('')[6];

    units[key] = value;

});

問題のJSBin

4

3 に答える 3

0

これが役立つと思います。

var units = [];

$('thead th[style*="width:130px;line-height:1.2em;text-align:center"]').each(function() {

    key  = $(this).text();
    console.log(key);
    value = $(this).contents('input[type=text]').val();
     console.log(value);
    units[key] = value;

});

for(var i in units){
  console.log(units[i]);
}
于 2013-09-18T06:28:11.830 に答える