Используйте плагин this jQuery shiftbox plugin или this one.Как добавить shiftcheckbox в динамический сгенерированный флажок?
в JS
for (var hidx in hosts) {
var h = hosts[hidx];
var line_html = '<tr><td><input type="checkbox" class="input shiftCheckbox" value = "'+ hidx +'" data-fullname="'+ h +'"></input></td><td>' + h + '</td> </tr>';
tbody_hosts.append($(line_html));
}
Это динамически.
в HTML
<script src="/static/js/jquery.shiftcheckbox.js" type= "text/javascript" ></script>
<script type= "text/javascript" >
$(document).ready (function() {
$('.shiftCheckbox').shiftcheckbox();
});
</script>
Почему он не работает? Потому что это динамично?
Вы инициализацию вашей функциональности shiftcheckbox перед тем существуют флажки. Вместо того, чтобы объявлять его внутри блока document.ready, найдите способ добавления его после добавления динамического содержимого в dom. Есть и другие варианты: http://stackoverflow.com/questions/8690739/attaching-jquery-plugin-calls-to-dynamically-loaded-elements-via-jquery-on –