Re: [jQuery] Bindind keydown function to a form - submit on keydown (value change)

2010-01-20 Thread Nathan Klatt
function setFamily() {
  $('#family').css('font-family', $('#family :selected').val());
}
$().ready(function() {
  setFamily();
  $('#family').bind("change keypress", setFamily);
}

As a bonus, this will work if they press the first letter of the
option they're selecting - it's all good. :)

Nathan


[jQuery] Bindind keydown function to a form - submit on keydown (value change)

2010-01-20 Thread Mircea
Hi,
I am trying to make a form to run a function on keyup, keydown.
The markup is:


Georgia
Times New
Roman
Helvetica Neue Light


I made a function that change the font-family on click:


$(document).ready(function(){

$('#family').click(function() {
 value = $(this).val();
 $('.cica').css('font-family', value)
 });
});

//capture the down key
$("#family").bind("keydown", function(e) {
if (e.keyCode == 40) {
value = $(this).val();
$('#family').css('font-family', value)
return false; //prevent default behavior
}
});




I am trying to bind a keydown to this form so when I press Down key
the form change its value and execute the function - change the font-
family.
It looks that my bind keydown does nothing. What should I change here?

Thank you.