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
}
})();
精彩评论