How do I insert an image instead of using text in Javascript? -
i want utilize hyperlink show image instead of using text in below starred text not sure how it. possible within javascript?? have tried looking @ other questions around these same parameters not sure how translate tose answers question. thanks!
var user; var take = function(choice) { user = choice; } var computerchoice = math.random(); if (computerchoice < 0.34) { computerchoice = "rock"; } else if (computerchoice < 0.67) { computerchoice = "paper"; } else { computerchoice = "scissors"; } var compare = function(choice1, choice2) { if (choice1 === choice2) { document.getelementbyid("result").innerhtml = "tie!"; } else if (choice1 === "rock") { if (choice2 === "scissors") { document.getelementbyid("result").innerhtml = "you win!"; } else { document.getelementbyid("result").innerhtml = "you lose!"; } } else if (choice1 === "paper") { if (choice2 === "rock") { document.getelementbyid("result").innerhtml = "you win!"; } else if (choice2 ==="scissors") { document.getelementbyid("result").innerhtml = "you lose!"; } } else if (choice1 === "scissors") { if (choice2 === "rock") { document.getelementbyid("result").innerhtml = "you lose!"; } else if (choice2 === "paper") { document.getelementbyid("result").innerhtml = "you win!"; } } else { document.getelementbyid("result").innerhtml = "error!"; } }
yo need enter:
document.getelementbyid("result").innerhtml = "<img src='yourimg' alt='yourimgtext'/>" where "yourimg" image want show.
javascript
No comments:
Post a Comment