Drupal7 work with jquery in a module

I agree that there are better ways to do this but some times you need just a few functions or need php to help create a jquery function inside a module 

	$output ='<script>
	(function($) {
Drupal.behaviors.myBehavior = {
  attach: function (context, settings) {
    //code starts
 $(document).ready(function() {
	 alert("hello");
 });
 
    //code ends
  }
};
})(jQuery);
	</script>';