fix for how to remove remove white spaces using javascript/jquery | issues with trim()
How to remove white spaces from the string seems to be a big question. Whether we have global javascript in-built functions that we can use or do we need to write our own custom methods.
Then I thought of going through Jquery way of using trim() method but then finally end up issues in IE7 ( Internet explorer).
var stringValue= ” suresh web developer bangalore”;
You see white spaces in a variable to get rid of it I tried using
Jquery
$(stringValue).trim(); /*issues with IE7*/
So then finally thought of using regular expression
$(stringValue).replace(/(^[\s\xA0]+|[\s\xA0]+$)/g, ”);
Worked like a charm.
Hope this will help.
3 Responses to fix for how to remove remove white spaces using javascript/jquery | issues with trim()
Leave a Reply Cancel reply
Latest posts
- bootstrap popover | bootstrap popover hide on click | bootstrap popover hide on document.click
- Avoid console errors in browsers that lack a console | HTML5 boilerplate
- getting started with Sublime editor | how to install zen coding | zen coding for sublime editor
- getting started with backbone | Models in Backbone
- How to delete a model in backbone







Hi and thanks for taking the time to describe the terminlogy to the newcomers!
Mate! This website is cool. How do you make it look like this !?
I can do it for you as well. Its all wordpress theme customization