Reputation: 3661
I'm using PHP tidy and it automatically indents markup, adds tabs and spaces. Please take a look at this.
I got 2 questions:
Upvotes: 0
Views: 1258
Reputation: 130371
As of JavaScript 1.8.1 (ES5) you can use normal string.trim()
var orig = " foo ";
alert( orig.trim() );
// "foo"
Upvotes: 1
Reputation: 154888
You're getting spaces because your options' text is on a separate line in HTML with indenting. You could remove them first:
$("#users option").text(function(i, text) {
return $.trim(text);
});
As for the placeholder, use .attr("placeholder", ...)
instead of .val(...)
:
input = $( "<input>" )
.appendTo( wrapper )
.attr( "placeholder", value )
Upvotes: 2
Reputation: 1463
Trim left and right spaces of a string
string.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
Regarding to placeholder, you can try jQuery-Placeholder
Upvotes: 0