tags:

views:

10

answers:

0

Hi all,

I'm using an xml file to generate some links which i would like to then be able to click on to populate an input box:

$(xmlResponse).find('types').each(function(){
                        var id = $(this).attr('id');
                        var type = $(this).find('type').text();                     
                        $('<span title=\"'+type+'\" class=\"type\">'+type+'</span>').appendTo('#types');                        
                    });

$('span.type').click(function() {    
        var title = $(this).attr('title');
        $("input[name='type']").val(title);
      });

But for some reason clicking on the liks does not populate the input box. It does work if the span is hard coded into the page for example:

<span title="text to populate" class="type">test</span>

I'm guessing that the XML is not getting loaded into the DOM in the right way (or something like that)

Any Ideas?