jquery手风琴点击事件跟踪

时间:2013-06-07 15:58:06

标签: jquery events click accordion click-tracking

我正在使用jquery手风琴来显示不同的信息,我的手风琴看起来像这样:`

<div id="accordion">
   <h3>Category1</h3>
   <div id="section1">
         < logic to display data for category 1 >
   </div>
   <h3>Category2</h3>
   <div id="section2">
         < logic to display data for category 2 >
   </div>
   <h3>Category3</h3>
   <div id="section3">
        < logic to display data for category 3 >
   </div>
   <h3>Category4</h3>
   <div id="section4">
        < logic to display data for category 4 >
   </div>
   <h3>Category5</h3>
   <div id="section5">
      < logic to display data for category 5 >
   </div>
</div>`

我想知道如何跟踪每个标题点击的次数,我需要将每个标题的点击次数发送到服务器端程序。谢谢您的帮助!

1 个答案:

答案 0 :(得分:1)

我不知道它是否显而易见但您可以在每次点击标题时将信息发送到服务器:

$('#accordion > h3').click(function(e){
   var header = $(this).html();
   //then send an ajax request to the server
   $.post(yoururl,{category:header});
});