Created
March 11, 2016 01:42
-
-
Save MuratOrs/15418658df72fc1f5ad3 to your computer and use it in GitHub Desktop.
Подставление изображения при клике
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Javascript</title> | |
</head> | |
<body> | |
<img src="http://lorempixel.com/g/500/400" alt="" id="image" onclick="changeImage()"> | |
<p id="paragraph">paragraph</p> | |
<h2 id="test">Как ваши дела, уважаемый?</h2> | |
<script> | |
function changeImage(){ | |
var image = document.getElementById('image'); | |
if (image.src.match("lorempixel")){ | |
image.src="http://lorempixel.com/g/250/250"; | |
} else{ | |
image.src="http://lorempixel.com/g/350/350"; | |
} | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment