0

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>
Jitender
  • 7,593
  • 30
  • 104
  • 210

3 Answers3

3

Use jQuery's trim:

$.trim($('div').text())

text() returns a string so you are trying to use the browser's built in trim which IE8 does not have.

James Montagne
  • 77,516
  • 14
  • 110
  • 130
1

try below

$.trim($('div').text())
Santosh
  • 12,175
  • 4
  • 41
  • 72
0

Use $.trim() jquery method instead:

console.log($.trim($('div').text()))
A. Wolff
  • 74,033
  • 9
  • 94
  • 155