js

[jQuery] img ํƒœ๊ทธ ํด๋ฆญ์‹œ ์ƒˆ์ฐฝ ํŒ์—… ๋„์šฐ๊ธฐ

natrue 2021. 4. 27. 11:14
728x90

image.jsp

$img = $('<img src="์ด๋ฏธ์ง€ ์ฃผ์†Œ" class="ํด๋ž˜์Šค๋ช…" alt="์ด๋ฏธ์ง€ ์„ค๋ช…"/>');
$img.on('click',function(){
  //window.open(this.src);
  var self = this;
    $.ajax({
      url:"../html/popupImage.html",  
      }).done(function(result){
        result = result.replace("\"src\"",self.src)
        result = result.replace("<p></p>", "<p>"+self.alt+"</p>")
        var wnd = window.open("");
        wnd.document.write(result);
    });
});

var self = this;

self ๋Œ€์‹  this๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ํ˜„์žฌ ๊ฐ์ฒด๋ฅผ ์ฐธ์กฐ

 

popupImage.html

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Image Popup</title>
<style>
  body {margin:25px;}

  div.polaroid {
    width: 100%;
    background-color: white;
    box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
    margin-bottom: 25px;
  }

  div.container {
  	padding: 10px 20px;
  }
</style>
</head>	
<body>
  <div class="polaroid">
    <img src="src" style="width:100%">
    <div class="container">
     <p></p>
    </div>
  </div>
</body>
</html>
 

CSS Image Gallery

CSS Image Gallery CSS can be used to create an image gallery. Add a description of the image here Add a description of the image here Add a description of the image here Add a description of the image here Image Gallery The following image gallery is creat

www.w3schools.com