| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Displaying text and then removing it...
I wanna display some text for 5 seconds and then remove it, this is the code i got so far...
document.getElementById('option' + id).innerHTML += 'You have already voted'; this displays the text in the right place, but i want it to only last for 3 or 4 seconds and then remove itself... anyone got any ideas? |
|
#2
|
|||
|
|||
|
you could do
function settext(thevalue,id){ document.getElementById('option'+id).innerHTML = thevalue; } window.setTimeout(settext('',1),3000); or maybe even window.setTimeout(function(){document.getElementBy Id('option'+id).innerHTML = thevalue;},3000); Im not sure if the second one will work, but I cant see why not. hope that helps or is understandable |
|
#3
|
|||
|
|||
|
well the second one worked, once i removed the 'window' bit from the front...
but that waited 3 seconds and then displayed the text... i wanted to immediately display the text and then remove it after 3 seconds... |
|
#4
|
|||
|
|||
|
ok try
Code:
function settext(id){
document.getElementById('option'+id).innerHTML = 'You have already voted';
setTimeout(function(){document.getElementBy Id('option'+id).innerHTML = '';},3000);
}
then you just call that function to set the text for that given box. e.g settext(boxidhere); |
![]() |
| Viewing: Tutorialized Forums > Desktop Programming > Visual C > Displaying text and then removing it... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|