开发者

Is there a way to keep track of javascript hits?

I am populating a table based on a javascript function. I want to limit the data entered to 2, afterwhich I hide the table. Is there a way to track how many hits the javascript code gets hit?

function addNewRow() {
    $('#displayInjuryTable tr:last').after('<tr><td style="font-size:smaller;" class="name"></td><td style="font-size:smaller;" class="address"></td></tr>');
    var $tr = $('#displayInjuryTable tr:last');
    var propertyCondition = $('#txtInj开发者_C百科uryAddress').val();


    $tr.find('.name').text($('#txtInjuryName').val());
    if (propertyCondition != "") {
        $tr.find('.address').text($('#txtInjuryAddress').val() + ', ' + $('#txtInjuryCity').val() + ' ' + $('#txtInjuryState').val() + ' ' + $('#txtInjuryZip').val());
 }


var someCounter = 0

function addNewRow() {
  if(someCounter>1) {
    return
  }   
  someCounter++
 ...your code...
}


var addNewRow = (function(){
    var count = 0;
    return function(){
        if (++count === 2) {
            //hide feature 
            return;
        }
        ... // your code here
    }
})();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜