item1
、item2
、item3
、の順序付けられていないリストがありitem4
、それぞれがdiv
前後にあるとします。
<ul>
<div><li>item1</li></div>
<div class="current"><li>item2</li></div>
<div><li>item3</li></div>
<div><li>item4</li></div>
</ul>
itemX をクリックするたびに、itemX.html が読み込まれ、itemX の周りの div に現在のクラス属性が与えられます。現在、私は4つの項目に対して4つの関数を別々に書いていますが、それらはほとんど同じに見えます. では、任意の itemX で機能し、itemX.html をロードし、その div の属性を変更する一般的な関数を作成するにはどうすればよいでしょうか? 私の現在のコードは冗長に思えます。