jQuery を使用して ListBoxes から選択した値を取得し、データベースに格納しました。
var hdn2 = "";
jQuery('select[name$=ListMyITProgramming] > option').each(function () {
hdn2 += jQuery(this).attr('value') + ',';
});
alert(hdn2);
値ではなく選択したテキストを取得するのを手伝ってくれる人はいますか?
使用できますtext()
:
var hdn2 = "";
jQuery('select[name$=ListMyITProgramming] > option').each(function () {
hdn2 += jQuery(this).text() + ',';
});
alert(hdn2);
ただし、次を使用してコードを簡素化 (および末尾の を削除,
)できmap()
ます。
var hdn2 = jQuery('select[name$=ListMyITProgramming] > option').map(function () {
return this.innerHTML; // I used the native DOM property here for speed
}).get().join(',');