Skip to content

Instantly share code, notes, and snippets.

@kanreisa
Last active December 10, 2015 16:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kanreisa/4463433 to your computer and use it in GitHub Desktop.
Save kanreisa/4463433 to your computer and use it in GitHub Desktop.
// 一番最初に実行する
window.sessionStorage.setItem('total', 0);
// ♪ここから
// load
var total = parseInt(window.sessionStorage.getItem('total'), 10);
// totaling
total += (function () {
var total = 0;
var prices = document.getElementsByClassName('price');
for (var i = 0; prices.length > i; i++) {
total += parseInt(prices[i].innerText.replace('¥ ', '').replace(',', ''));
}
return total;
})();
// save
window.sessionStorage.setItem('total', total);
// 合計の表示
total;
// 次のページへ(あれば)飛ぶ
var navs = document.getElementsByClassName('num-pages');
for (var i = 0; navs.length > i; i++) {
var links = navs[i].getElementsByTagName('a');
for (var j = 0; links.length > j; j++) {
if (links[j].innerText == '次へ »') {
window.location.href = links[j].href;
}
}
}
// ♪繰り返し
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment