probleme selection Radio
by LorenzoFR
HTML
<link rel="stylesheet" href="http://knacss.com/css/knacss.css">
<div class="mod w25 center txtcenter" id="cible">
<input type="checkbox" value="1" name="tx1">texte 1<br>
<input type="checkbox" value="2" name="tx2">texte 2<br>
<input type="checkbox" value="3" name="tx3">texte 3<br>
<input type="checkbox" value="4" name="tx4">texte 4<br>
<input type="checkbox" value="5" name="tx5">texte 5<br>
<input type="checkbox" value="6" name="tx6">texte 6<br>
<input type="checkbox" value="7" name="tx7">texte 7<br>
<input type="checkbox" value="8" name="tx8">texte 8<br>
</div>
CSS
#cible{
font-size: 130%;
background-color: ;
}
#trace {
font: monospace;
background-color: #ffffaa;
}
JavaScript
$ = jQuery.noConflict();
$(document).ready(function() {
var nbInput = $('#cible>input').length;
function interval(){
//$('#trace').html('');
var idCourant = $('#cible>input:checked').index();
$('#cible>input:checked').prop('checked', false);
console.log('idCourant : ', idCourant);
idCourant++;
if( idCourant > nbInput ){
idCourant = 0;
}
$('#cible>input:eq('+idCourant+')').prop('checked', true);
console.log(idCourant, ' == ', $('#cible>input:checked').index());
console.log('-------------------------------');
}
var idInterval = setInterval(interval, 500);
$(window).on('keydown', function(ev){
if( ev.which == 27 ){
clearInterval(idInterval);
}
});
});