str.replace(/(^\s+)|(\s+$)/g, "");
他にもいかにも関数っぽくするなら
String.prototype.trim = function() {
return this.replace(/(^\s+)|(\s+$)/g, "");
}
function func(str) {
return str.trim();
}jQueryを使える環境なら
$.trim(val);
str.replace(/(^\s+)|(\s+$)/g, "");
String.prototype.trim = function() {
return this.replace(/(^\s+)|(\s+$)/g, "");
}
function func(str) {
return str.trim();
}$.trim(val);
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<script type="text/javascript">
window.onload = function() {
setTimeout(doScroll, 100);
}
function doScroll() {
if (window.pageYOffset == 0) {
window.scroll(0, 1);
}
}
</script><meta name="apple-mobile-web-app-capable" content="yes" />
<object> <param name="wmode" value="transparent" /> </object>
<embed wmode="transparent"></embed>
var flashvars = {};
var params = { wmode : "transparent" };
var attributes = {};
swfobject.embedSWF("./hoge.swf", "hoge", "100%", "100%", "9.0.0", "expressInstall.swf", flashvars, params, attributes);