1
var str = '2,4';
var accept_message = str.split(',');
var accept_message_html = '';
var accpet_message_Obj = {
1: 'Friends',
2: 'Models',
3: 'Premiums',
4: 'Basics'
};
$.each(accpet_message_Obj, function(key, value) {
accept_message_html += '<span style="padding-right:30px;"><input style="float:none;" type="checkbox" name="privacy_options[]"' + (key == accept_message[key] ? ' checked="checked"' : '') + ' value="' + key + '" /> ' + value + '</span>\n';
});
$('#content-area').html(accept_message_html);
以上編碼不工作。我需要checkbox
檢查其值是2
和4
但沒有選擇複選框。 :(
http://jsfiddle.net/satpalsingh/v6br6ydw/ – Satpal
是由於@Satpal – Chinmay235