javascript - How to append string in jQuery without quotes? -


let's have paragraph:

<p>txt0</p> 

... , want append text:

$("p").append("_txt1"); $("p").append("_txt2"); $("p").append("_txt3"); 

the result be, expected:

txt0_txt1_txt2_txt3 

however if inspect result in browser, is:

<p>    "txt0"    "_txt1"    "_txt2"    "_txt3" </p> 

there 4 different strings rendered one. problem i'm creating flash object dynamically , appending strings way not work because of quotes. need 1 continuous string this:

<p>    txt0_txt1_txt2_txt3 </p> 

is there way append in such way? or remove quotes afterwards?

ps. before make 1 big string before appending, won't work because string big , ex. works in chrome not in firefox or iexplorer (but that's different issue).

use text, otherwise you're appending new textnode everytime:

var $p = $('p'); $p.text('txt0'); $p.text($p.text() + '_txt1'); 

or textcontent it's less confusing:

var p = $('p')[0]; p.textcontent += 'txt0'; p.textcontent += '_txt1'; ... 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -