Ezt a programkódot láttam.
Csak hogy van vele egy bajom... hogy ha az other radiobuttonbe ír (amelyikhez tartozik szövegbevitel mező ( a többihez nem)), akkor nem jelöli ki egyből azt a rádiogombot. Csak akkor ha befejeztem a szöveg írását és ki kattintok belőle.
Hogyan tudom úgy átírni a kódot, hogy amikor éppen írnak bele szöveget, már akkor kijelölje a radiogombot?
$(document).ready(function(){
// find any text input in chooseSource list, and cycle through each
$('#chooseSource input:text').each(function(){
// these are both used twice, let's store them to be more efficient
// the text input
var $inputTxt = $(this);
// the associated radio button (az input text-hez tartozó radio button hozzáadása)
var $radioBtn = $inputTxt.siblings('input:radio');
// listen for the blur event on the text input
$inputTxt.blur(function(){
// if text input has text
if ( $inputTxt.val() !='' ) {
// select radio button
$radioBtn.attr('checked',true);
}
}).trigger($radioBtn.change);
// listen for the change event on the radio button
$radioBtn.change(function(){
// if it is checked, focus on text input
if ( this.checked ) { $inputTxt.focus(); }
});
}); // close each()
});