I want to get the closest id of the parent li and allocate it to a pre tag. In a div, which surrounds the pre tag, there must be an onclick event with the same id. What i have so far:
Adding the id to the pre tag from the parent li:
$('pre').each(function(){
$(this).attr('id', $(this).closest('li').attr('id')+'_pre');
});
The onclick event (i added this to a php variable)
$SelectButton = '<span class="control-copytextarea" onclick="return fieldtoclipboard.copyfield(event, \\\'id1\\\')">[Select and Copy]</span><br />';
Prepend just above the pre tag a span with the onclick
$('.surroundpre').prepend('$SelectButton');
The only thing i don't know how to achieve: in the php variable should id1 also be replaced with the same id as already is added to the pre tag