1

フォームのフォームフィールドのタイプを取得しようとしていますが、コンボボックスで機能しないようです

入力は機能しますが、選択は機能せず、「select-one」と明確に表示されます

attr

<select id="test">
    <option value=1>1</option>
</select>

<input type="text" id="test2">

<hr>type of select:
<div id="a"></div>
<hr>type of input
<div id="b"></div>

var f = $('#test').attr('type');
$('#a').html(f);
var f = $('#test2').attr('type');
$('#b').html(f);​

私は何かが足りないのですか?またはそれはバグですか?

参照: http: //jsfiddle.net/TZjE5/1/

4

1 に答える 1

1

.propの代わりに切り替えます.attr

var f = $('#test').prop('type');
$('#a').html(f);

type of select: select-one
于 2012-10-18T13:50:03.470 に答える