Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery file not loading on browser

When i open the html file on google chrome. It is just a blank page. Nothing is loading. If i take out the .js files it loads the content with the .css applied but never with the .js files. Whether I put the .js files in the or at the end of the it still does not show anything. I am using jquery btw and downloaded the file. all files are on the same folder. also tried both jquery-3.3.1.min.js and jquery-migrate-1.4.1.js if it makes a difference. Hoping someone can help. Thanks!

HTML:

<!DOCTYPE html>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" type="text/css" href="testing.css">
</head>
<body>
<div id="products">
  <h1 class="ui-widget-header">Blocks</h1>
  <div class="ui-widget-content">
    <ul>
      <li data-id="1" class="credit"> 10000$ </li>
      <li data-id="2" class="debit"> -10000$ </li>
      <li data-id="3" class="credit"> 10000$ </li>
      <li data-id="4" class="credit"> -10000$ </li>
      <li data-id="5" class="credit"> Bank </li>
      <li data-id="6" class="debit"> Loan </li>
    </ul>
  </div>
</div>

<div id="shoppingCart1" class="shoppingCart">
  <h1 class="ui-widget-header">Credit Side</h1>
  <div class="ui-widget-content">
    <ol>
      <li class="placeholder">Add your items here</li>
    </ol>
  </div>
</div>
<div id="shoppingCart2" class="shoppingCart">
  <h1 class="ui-widget-header">Debit side</h1>
  <div class="ui-widget-content">
    <ol>
      <li class="placeholder">Add your items here</li>
    </ol>
  </div>
</div>


<script type="text/javascript" src="jquery-migrate-1.4.1.js"></script>
<script type="text/javascript" src="testing.js"></script>


</body>
</html>

.JS

$("#products li").draggable({
  appendTo: "body",
  helper: "clone"
});
$("#shoppingCart1 ol").droppable({
  activeClass: "ui-state-default",
  hoverClass: "ui-state-hover",
  accept: ".credit",
  drop: function(event, ui) {
    var self = $(this);
    self.find(".placeholder").remove();
    var productid = ui.draggable.attr("data-id");
    if (self.find("[data-id=" + productid + "]").length) return;
    $("<li></li>", {
      "text": ui.draggable.text(),
      "data-id": productid
    }).appendTo(this);
    // To remove item from other shopping cart do this
    var cartid = self.closest('.shoppingCart').attr('id');
    $(".shoppingCart:not(#" + cartid + ") [data-id=" + productid + "]").remove();
  }
}).sortable({
  items: "li:not(.placeholder)",
  sort: function() {
    $(this).removeClass("ui-state-default");
  }
});
// Second cart
$("#shoppingCart2 ol").droppable({
  activeClass: "ui-state-default",
  hoverClass: "ui-state-hover",
  accept: ".debit",
  drop: function(event, ui) {
    var self = $(this);
    self.find(".placeholder").remove();
    var productid = ui.draggable.attr("data-id");
    if (self.find("[data-id=" + productid + "]").length) return;
    $("<li></li>", {
      "text": ui.draggable.text(),
      "data-id": productid
    }).appendTo(this);
    // To remove item from other shopping chart do this
    var cartid = self.closest('.shoppingCart').attr('id');
    $(".shoppingCart:not(#" + cartid + ") [data-id=" + productid + "]").remove();
  }
}).sortable({
  items: "li:not(.placeholder)",
  sort: function() {
    $(this).removeClass("ui-state-default");
  }
});

.CSS

h1 { padding: .2em; margin: 0; }
#products { float:left; width:200px; height: 600px; margin-right: 20px; }
#products ul {list-style: disc; padding: 1em 0 1em 3em;}
.shoppingCart{ width: 200px; margin: 20px; float: left; }
.shoppingCart ol { margin: 0; padding: 1em 0 1em 3em; list-style-type: decimal;  }
like image 740
Ashley Avatar asked May 04 '26 19:05

Ashley


1 Answers

Use

<script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.js"></script>

Because jquery-migrate not contains entire jquery code. Of course you can include script from local.

like image 149
Profesor08 Avatar answered May 06 '26 10:05

Profesor08



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!