Skip to content

Instantly share code, notes, and snippets.

@MuratOrs
Created March 11, 2016 01:42
Show Gist options
  • Save MuratOrs/15418658df72fc1f5ad3 to your computer and use it in GitHub Desktop.
Save MuratOrs/15418658df72fc1f5ad3 to your computer and use it in GitHub Desktop.
Подставление изображения при клике
<!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