Append a space with jQuery

72,951

Solution 1

How about

$("#mySelector").append(" "); // or with & nbsp;

Solution 2

In my case I did the following:

$('.colwid10a').each(function () {
    if ($(this).is(':empty')) {
        $(this).append(" ");
    }
});
$('.colwid12').each(function () {
    if ($(this).find('a').is(':empty')) {
        $(this).find('a').append(" ");
    }
});
Share:
72,951
Joel Harris
Author by

Joel Harris

SOreadytohelp

Updated on July 09, 2022

Comments

  • Joel Harris
    Joel Harris almost 2 years

    I'm trying to append a space using jQuery. Neither of these samples work:

      $("#mySelector").append($(" "));
      $("#mySelector").append($(" "));
    

    Any ideas?