When a string inside a div changes do something

JavaScript and client side scripting.

Moderator: General Moderators

User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: When a string inside a div changes do something

Post by Eran »

what's the content of the setInterval callback...
klevis miho
Forum Contributor
Posts: 413
Joined: Wed Oct 29, 2008 2:59 pm
Location: Albania
Contact:

Re: When a string inside a div changes do something

Post by klevis miho »

I don't really know what to put in the function.
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: When a string inside a div changes do something

Post by Eran »

It should be something like this:

Code: Select all

//Set the start value (could be empty)
var title = document.getElementById('cc_stream_info_song').innerHTML;

function check() {
      var currentTitle = document.getElementById('cc_stream_info_song').innerHTML;     
      if(title != currentTitle) {
            //get artist information
            title = currentTitle; //Update the variable to the current content
      }
}
setInterval(check, 10000);
klevis miho
Forum Contributor
Posts: 413
Joined: Wed Oct 29, 2008 2:59 pm
Location: Albania
Contact:

Re: When a string inside a div changes do something

Post by klevis miho »

Aaaaaaaa much much more simpler then thought.
Thnx again :) .
klevis miho
Forum Contributor
Posts: 413
Joined: Wed Oct 29, 2008 2:59 pm
Location: Albania
Contact:

Re: When a string inside a div changes do something

Post by klevis miho »

I tried it and worked perfectly.
Post Reply