Jquery – Getting text from title attribute of element while appending to it

domdom-manipulationjquery

I have function which append div (help icon) after all element with .help class.

jQuery().ready(function() {
     jQuery('.help').append('<div class="mark"></div>');
});

What do I need to add to that function to get information from title attribute of .help element?

I'm new in scripting.

Best Solution

Utilizing the fact that append() can also accept a function that will create the HTML string to append:

$('.help').append(function () {
    return '<div class="mark" title="' + $(this).attr('title') + '"></div>';
});