Search code examples
jquerycssfindpre

Jquery find 'pre' apply css


I'm using jquery to fetch some data and so far so good. Can I apply styling to the retrieved data? I would like to add a solid horizontal line after each pre tag.

$.get(dataSrc, function (data) {
      success:  function () {
       var tags = $(data).find('pre');
       $("#div1").empty().append(tags);
       };
});

Solution

  • You should use an each statement

    $('pre', $(data)).each(function(){
        // 'this' refers to the pre element
        $(this).append(your_line);
    })