santa santa - 1 year ago 174
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 = ....


Answer Source

You could use replace method.

var cleanUrl = myUrl.replace(/^#\?/, '');
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download