Skip to content

Instantly share code, notes, and snippets.

@hiamandeep
Created November 5, 2016 07:53
Show Gist options
  • Save hiamandeep/0ca5648eb311a67b761a963d173dade1 to your computer and use it in GitHub Desktop.
Save hiamandeep/0ca5648eb311a67b761a963d173dade1 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