Skip to content

Instantly share code, notes, and snippets.

@dirkakrid
Forked from hiamandeep/responsiveimg.html
Created October 4, 2017 08:19
Show Gist options
  • Save dirkakrid/8122d428f44104a7ae8b84c723fa8d21 to your computer and use it in GitHub Desktop.
Save dirkakrid/8122d428f44104a7ae8b84c723fa8d21 to your computer and use it in GitHub Desktop.
<html>
<head>
<title>Responsive Images</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<img src="example.png"/>
<img src="example2.png"/>
<img src="example3.png"/>
<script>
var totalImg = document.getElementsByTagName("img").length;
for(var i = 0; i < totalImg; i++){
var img = document.getElementsByTagName("img")[i];
var att = document.createAttribute("class");
att.value = "img-responsive";
img.setAttributeNode(att);
}
</script>
</body>
<html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment