问题描述
为什么此代码/示例在 Chrome 上不起作用,但在 Firefox 中却运行良好。用于排序的“字母顺序”和“数字”按钮单击的含义仅在 Firefox 中有效 乙 这段代码不是我的,我只是从中学习。
<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);
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)