Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

121
Views
Unable to remove image preview after click outside div or close button javascript PHP

I am working on Php with jquery, I have jquery Popup modal and right now i am displaying image preview,I want whenever i click outside modal or click on close button(close_btn_t)then image should remove and click on browse button selected image should display, how can i do this ? Here is my code

<div class="modal-content">
<div class="preivew-right-bar">
                    <span class="previewpostimage"><img id="thumb" src="blob:https://xxxxxxxxx/0d865270-6aee-4873-8c4a-16a67273e3e6" style="display: none;"></span>
                        
                                    <span class="close_btn_t">
                                    
<button type="button" id="closebtn"><span aria-hidden="true">×</span>
 </span>
                    </div>
    </div>  

I tried with following code

$('body').click(function (event) 
{
   if (
      event.target.matches(".button-close-modal") ||
      !event.target.closest(".modal-content")
    ) {
            $(".previewpostimage").html("");
            $('.previewpostimage').val('');
   }     
});
        
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!