How to make Avatar Images in jQuery

How to make avatar images in Jquery. Using Jquery we can switch the images. Learn how to create an avatar image with CSS. … height and width that looks good, and use the border-radius property to add rounded corners to an image.

Download complete code: Jquery Avatar Images

We have used bootstrap 4 for designing and Jquery for Images Switching.

// Code for Jquery

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://unpkg.com/aos@next/dist/aos.css" />
<style>
.avatar {
  vertical-align: middle;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  cursor: pointer;
}
</style>
</head>
<body>
 <div class="container">
   <div class="row mt-3">
      <div class="col-sm-4 offset-md-4">   
        <h2 class="mb-4">Avatar Images</h2>
        <img src="avatar1.png" id="av1" alt="Avatar" class="avatar">
        <img src="avatar2.png" id="av2" alt="Avatar" class="avatar ml-5">
        <img src="avatar3.png" id="av3" alt="Avatar" class="avatar ml-5">
      </div>
    </div>  
    <div class="row mt-3">
      <div class="col-sm-4 offset-md-4">   
        <span class=""> Resham</span>
        <span class="ml-5"> Mathew</span>
        <span class="ml-5"> Namrad</span>
      </div>
    </div>  
    <!-- Code for image show here  -->
   <div class="row mt-5"> 
     <div class="col-sm-4 offset-md-4"> 
      <span id="student_img" >
      </span>
    </div>
   </div>
   </div>  
 </div>
</body>
</html>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

<script>
     $(document).ready(function(){

      $('#av1').click(function() {
        var isCliked = true;
        if(isCliked)
        {
          $('#student_img').html('<div class="stu_detail1" data-aos="fade-left"><img class="card-img-top" id="stu_one" src="avatar1.png" style="width:50%"><h4 class="mt-2">Resham Halrt</h4><p>Chemical Engineer</p></div>')
        }
      });

      $('#av2').click(function() {
        var isCliked = true;
        if(isCliked)
        {
          $('#student_img').html('<div class="stu_detail2" data-aos="fade-right"><img class="card-img-top" id="stu_two" src="avatar2.png" style="width:50%"><h4 class="mt-2">Mathew Deogrd</h4><p>Software Developer</p></div>')
        }
      });

      $('#av3').click(function() {
        var isCliked = true;
        if(isCliked)
        {
          $('#student_img').html('<div class="stu_detail3" data-aos="fade-up"><img class="card-img-top"  id="stu_three" src="avatar3.png"  style="width:50%"><h4 class="mt-2">Namrad Hand</h4><p>Sales Executive</p></div>')
        }
      });
    });
</script>    

<script src="https://unpkg.com/aos@next/dist/aos.js"></script>
<script>
  AOS.init();
</script>

//

 

 

 

 

 

Avatar Images

Avatar Avatar Avatar
Resham Mathew Namrad
 

 

Leave a Reply

Your email address will not be published. Required fields are marked *