I am removing extra space using trim method which is working fine in all browser except IE8.
<head>
<script type="text/javascript" src="jquery-1.8.3.js"></script>
<script type="text/javascript">
$(function(){
$('a').click(function(){
console.log($('div').text().trim())
})})
</script>
</head>
<body>
<div> test </div>
<a href="javascript:void(0)">pick test</a>
</body>