Question: I'm trying to replace a div with another div every 30 seconds.

I have the below running however the div is not being replaced;

```
$( ".class1" ).setInterval(function() {
    $( this ).replaceWith('<div class="class2">54</div>');
} 3000);

```

What am I doing wrong?

Answer: 
Are you trying to change the text of the `span`?

```
 setInterval(changeText, 30000);
 function changeText(){
     if($(".class1").text() == "Hello World"){
          $(".class1").replaceWith("<div class='.class1'>My New Div</div>");
     }else{
         $(".class1").replaceWith("<div class='.class1'>Hello world</div>");
     }
 }

```
For toggling the text. You can use:

```
setInterval(function(){
  $('.class1').text($('.class1').text() == ".class1" ? "hello world" : ".class1")
},30000);

```

**[Working Demo](http://jsfiddle.net/yuj56aze/)**