Search code examples
javascriptjquerysafaridhtml

safari doesn't (dynamically) refresh $.html() content


I have the following piece of code

$('#charactersRemaining').html(123-countChars(this.value));

Works in all browsers except Safari. Even in Safari, if I click the content in the div area ( of id=charactersRemaining), it refreshes, but it doesn't refresh automatically/dynamically

Any way to force Safari to refresh?

$().html('new content');

Update: I have used the following 'hack' (for safari). But still interested to know if I have missed any technical detail

$('#x').html('new'); 
$('#x').hide(); 
$('#x').fadeIn(); // or you could use .show();

Solution

  • Finally, I found the issue. I had an image nearby (may be floating/layering over the text). Thus Safari didn't redraw the underlying text (or some quirk).

    Anyway moved the image around and it works in safari too