Code inside attached behavior not executed I nested jQuery code inside a behavior. I don't understand, why the code does not execute. I would be appleased if you could give me a hint on what I probably did wrong.

My code:

   $(function (){
    Drupal.behaviors.block_sidebar_register_buttons = {
        attach: function (context, settings) {
            var element = $('#block_register_buttons');
            //...
        }
    };
});
Drupal disables the $ namespace for jQuery, to avoid potential conflicts with other libraries. Therefore the wrapping $() DOM-ready-function will neither be executed, nor can the $('#something') selector be used inside. Wrap your behavior with this instead:

(function ($, Drupal) {
  //inside the wrapper you can use the usual jQuery $ notation
  Drupal.behaviors.block_sidebar_register_buttons = {
    attach: function (context, settings) {
      var element = $('#block_register_buttons');
      //...
   }
  }
}(jQuery, Drupal));