Two Javascript Tricks: click() and trim()

Man my poor blog hasn’t been updated in quite some time. What on earth could I do to remedy that situation? Wait, I GOT IT! I’ll add a new post! 🙂

Here are two really simple but really useful JavaScript tricks.



The above is handy when you want to programmatically click a button for the user based on whatever logic you write. I used it to fire some ATLAS (now called ASP.Net AJAX) animations after I validated some fields.


Add the following to your JavaScript library to trim the white space from the beginning and end of your strings.

	return this.replace(/^\s*|\s*$/g,'');

The above allows you to do this: xString = xString.trim();

Check out this Wikipedia article on ‘trim’. There are examples on how to trim a string for numerous programming languages.

2 thoughts on “Two Javascript Tricks: click() and trim()

Leave a Reply

Your email address will not be published.