-1

I want to change the content of the p tag after three seconds using setInterval() method. Then after three seconds I want to change the content inside of the p tag, with a new interval of 5 seconds. This is my code snippet:

background.js

var notify;
var word=function(){
    $.get("http://localhost/chrome-notification/dosya.php", function (data) {
        $('#container').html(data);
    });
};

setInterval(word,3000);

setInterval(function(){
    $.get("http://localhost/chrome-notification/", function (response) {
      notify=$(response).getElementsByTagName('p')[0].innerHTML;
    });
},5000);

index.html

<html lang="en">
<head>
    <meta charset="UTF-8">
    <script language="JavaScript" type="text/javascript" src="jquery.js"></script>
    <script type="text/javascript" src="background.js"></script>
    <title>Vocabulary</title>
</head>

<body>

<p id="container">

</p>

</body>
</html>
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129

3 Answers3

1

This can be done in pure js.

var text = document.getElementById('container').innerHTML;

Is this what you need?

zehata
  • 3,354
  • 2
  • 14
  • 23
0

Since you are using jQuery, you can simply do $(response).find('p:eq(0)').html()

I've written some more examples here https://jsbin.com/modaxayaki/edit?html,js,console

-3

If i understaned good, i would recommend adding CSS and linking it to html. (If is that for what you need it for)

Make tag in css and customize it