santa santa - 9 months ago 57
jQuery Question

ltrim with jQuery?

I am using jQuery to capture an encoded URL.

I looks something like: #?var=asdasdasdasdasd

I need to strip "#?" at the beginning of the string. In PHP I'd use ltrim. How can I do this with jQuery or plain JS?

var myUrl = $(this).attr("href");
var cleanUrl = ....



You could use replace method.

var cleanUrl = myUrl.replace(/^#\?/, '');