1

I need to convert this code line (it focuses the cursor to the first input of a form) to Drupal behaviourism. Can anyone help me put it the Drupal bushido way?

jQuery("input:text:visible:first").focus();

1 Answer 1

3
jQuery("input:text:visible:first").focus();

Becomes

Drupal.behaviors.focustextfield = function(context) {
  $("input:text:visible:first:not(.focustextfield-procd)", context).addClass("focustextfield-procd").focus();
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.