Alex Rivera | Logout

Append a space with jQuery

Asked 2009-09-30T22:55:50.440
24

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

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

Any ideas?

Edit
Report

1 Answer

-1

And, create a JQuery Plugin function to reuse it whenever you need to put space. This way you will be consistent throughout.

if(!$.space) {
        $.space = function​(noOfSpaces) {
            var space = " ", returnValue = "";
            for(var index=0; index < noOfSpaces; index++) {
                returnValue += space;
            }
            return returnValue;
        }
    }

alert("Stack" + $.space(6) + "Overflow");
answered 2012-09-05T11:47:56.427

Your Answer