Behavior not attaching to a form element I have a module for relating pieces of content to each other. My module successfully adds a field to all content-types that is essentially a list of integers, meant to hold node ID's. I want AJAX functionality such that when the user begins typing the title of a node, autocomplete suggestions begin appearing. I've already implemented the web service via Drupal to retrieve nodes based on partial titles, and that's working very well. The problem is now attaching the behavior I want to the form element. 

Two problems:

1) No way to uniquely identify the form element in question. The class name is not going to be usable if there are more than one of them, which there may be. How can I force a unique class name? Something like class="content-relation" for each one?

2) The behavior I want to attach is failing to do so. I've tried a couple different ways...here they all are.

Way 1:

Drupal.behaviors.content_relation =  {
    attach: function(context) {
        jQuery('input.form-text').change(function() {
            var ul = jQuery('&lt;ul /&gt;')
                .css({position: 'absolute', top: '0px', left: '0px'});

            jQuery.get(
                '/api/'+jQuery(this).val(),
                function (data) {
                    jQuery.each(data, function(item){
                        var li = jQuery('&lt;li&gt;');
                        li.html(item.title);
                        li.appendTo(ul);
                    });
                }
            );
        });
    }
};


Way 2:

jQuery.ready(function(){
    jQuery('input.form-text').live('change', function() {
        var ul = jQuery('&lt;ul /&gt;')
            .css({position: 'absolute', top: '0px', left: '0px'});

        jQuery.get(
            '/api/'+jQuery(this).val(),
            function (data) {
                jQuery.each(data, function(item){
                    var li = jQuery('&lt;li&gt;');
                    li.html(item.title);
                    li.appendTo(ul);
                });
            }
        );
    });
});


...but none of the inputs with a class of form-text have this function listed in their change-listeners, nor do they respond to changes. Thoughts?
You shouldn't need a single line of JS to have autocomplete textfield working in D6/D7. Please see the Form API refrence.