javascript - Push text to array then append to div - displaying text in div twice in IE8 -


using mouseup, i'm appending multiple values array.

var myarray = []; $("#button").mouseup(function() {           myarray.push(" play contact sports");  ]); 

then appending div using button

$("#button2").mouseup(function() {          $('#output').append(myarray+'');  ]); 

it works fine in browsers apart ie8 text push after 1 click display twice.

play contact sports play contact sports 

there no comma. know cause might be? or alternative might work?

i'm not clear on want do, i'd wrap each text node you're appending element , more explicit array-to-string conversion. in click handler ensure event stopped:

$("#button2").mouseup( function(event) {    event.stoppropagation();    event.preventdefault();    $('<p></p>').html( myarray.join(',') ).appendto('#output');    return false; } ); 

Comments

Popular posts from this blog

ios - Memory not freeing up after popping viewcontroller using ARC -

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -