looking for some solutions? You are welcome.

SOLVED: JQuery code that hides and shows divs doesn't work when integrated with my live site


not sure what I'm doing wrong here. My code is fairly simple, it simply checks the dimensions of an image and shows/hides divs with the appropriate messages based on the results of the check.

Here is the code on JSFiddle and here is the live site.

var _URL = window.URL || window.webkitURL;

$("#filecheck").change(function() {
  var file, img;

  if ((file = this.files[0])) {
    img = new Image();

    img.onload = function() {
      if (this.width < 1800 && this.height < 1800) {
        $('.pass').css('display', 'none');
                $('.fail').css('display', 'block');
      else {
        $('.pass').css('display', 'block');
                $('.fail').css('display', 'none');
    img.src = _URL.createObjectURL(file);
.pass {
  display: none;

.fail {
  display: none;
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="file" id="filecheck" />
<div class="pass">
image quality good

<div class="fail">
image quality too low

Can anyone see anything that I've done wrong here? It's probably something really basic but I'm pretty new to this.

Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots

No comments: