Petros Kyriakou
Petros Kyriakou

Reputation: 5343

Textarea has mysterious whitespace

For some reason the textarea i am appending to using jquery creates white space.

javascript

$(document).ready(function(){
  var artistName = $("#artist-name").text();
  var songName = $("#song-title").text();
  var prepopulated_tweet = "@Myrfriends @RndomPerson \"you'll love this track\" @" + artistName + " - " + songName + " #Rock #Pop #Soul Krilex.******.co/rx11"
  $("#tweet-message").append(prepopulated_tweet);
})

html

<textarea name="name" rows="4" cols="80" id="tweet-message"></textarea>

output

@Myrfriends @RndomPerson "you'll love this track" @Krilex -

Pieces - Red

#Rock #Pop #Soul Krilex.*****.co/rx11

any clues?

Upvotes: 0

Views: 93

Answers (1)

Uzbekjon
Uzbekjon

Reputation: 11813

Content in #song-title element must have new lines.

Given:

<div id="song-title">
  Pieces - Red
</div>

$("#song-title").text(); would return:

"
  Pieces - Red
"

Upvotes: 6

Related Questions