tags:

views:

32

answers:

2

I have the following paragraph to which content of array added

$('#pop').html(arr.join('<br>'))

I want to do like clear and add.

$('#pop').text('').html(arr.join('<br>'))
A: 

uh.. keep using .html?

$('<p>').html( [1,2].join('<br>') ).html('').html( [2,3].join('<br>') )

Though I don't see the point of doing .html('') if you're going to replace it with new text anyway ...

meder
ut it not get clear. When i say $('#pop').html(arr.join('<br>')) on click, it append content to earlier one. I check to see if arr has previous value but no arr has no issue. So issue probably in this statement. i check in IE7.
Mario
Determine if the html has content by doing if ( $('#pop').html().length ) { }
meder
A: 

text in like html only with HTML tags. So there is no need to call text("") before replacing the whole HTML content of that element with html.

Gumbo
but it not get clear. When i say $('#pop').html(arr.join('<br>')) on click, it append content to earlier one. I check to see if arr has previous value but no arr has no issue. So issue probably in this statement. i check in IE7.
Mario
@Mario: Can you give us an example?
Gumbo
Do i open new thread or post code here?
Mario
@Mario: Post it here, it belongs to this question.
Gumbo