2021年3月5日星期五

Why is this jsFiddle working in Firefox but not in Chrome? it is a jquery sort example [duplicate]

Why is this code/example not working on Chrome, but in Firefox it works fine. Meaning on button click for "Alphabetical" and "Numerical" for sort works only in Firefox B This code is not mine, am just learning from it.

<div class="wrap">  <button id="alphBnt">Alphabetical</button>  <button id="numBnt">Numerical</button>  <div id="container">    <div class="box">      <h1>B<h1>      <h2>10.35</h2>      </div>      <div class="box">      <h1>A<h1>      <h2>100.05</h2>    </div>      <div class="box">      <h1>D<h1>      <h2>200</h2>      </div>      <div class="box">      <h1>C<h1>      <h2>5,510.25</h2>    </div>  </div>  
var $divs = $("div.box");    $('#alphBnt').on('click', function () {  var alphabeticallyOrderedDivs = $divs.sort(function (a, b) {      return $(a).find("h1").text() > $(b).find("h1").text();  });  $("#container").html(alphabeticallyOrderedDivs);    $('#numBnt').on('click', function () {  var numericallyOrderedDivs = $divs.sort(function (a, b) {      return $(a).find("h2").text() > $(b).find("h2").text();  });  $("#container").html(numericallyOrderedDivs);  

Sort Example in jsfiddle

https://stackoverflow.com/questions/66501319/why-is-this-jsfiddle-working-in-firefox-but-not-in-chrome-it-is-a-jquery-sort-e March 06, 2021 at 08:50AM

没有评论:

发表评论