Event in function JQuery
<p>I'm trying to make a function in jQuery that executes events. My goal is to make a function that puts a message in a field when the pages loads or when the user blanks the field. </p>

<pre><code>$(function () {

  function focusField(id, message) {
    parent = $(this);

    id.color("#C8C8C8");
    id.value(message);

    parent.delegate(id, 'focus', function() {
      if( id.val() == message ) {
        id.val("");
        id.color("black");
      };
    });

    parent.delegate(id, 'keyup', function() {
      if( id.val() == "") {
        id.val(message);
        id.color("#C8C8C8");
      }
    });
  };

  $(".content").focusField($("#emaillogin"), "Email");
</code></pre>

<p>This doesn't work cause I think I'm using the concept function wrong. Is there however a way to do it like this? With this I mean if it is possible to make a function then call it on an element but not in an event but call the events in the function. </p>

<p>Normal function use: $element.event(function). I want to bind events in my function to elements if this is possible.</p>

<p>Thanks in advance!</p>
