0
I need to make an application in javascript/jquery/html that counts the user’s clicks on the button and when the counter reaches 10 lock the button and displays an Alert, I don’t know why it’s not displaying. Does anyone know?
<head>
<title>Página</title> <!-- Add page title -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <!-- add Jquery CDN -->
<link href src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" media="screen"></script> <!-- add bootstrap css CDN -->
</head>
<body>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> <!-- add Bootstrap CDN -->
<link href="design.css" rel="stylesheet" medi="screen"> <!-- Add css in html -->
<div class="container">
<div class="row">
<div class="col-lg-12 tabela">
linha azul
</div>
</div>
</div>
<script type="text/javascript"> // all javascript/jquery code start here
function add_field()
{
var form = document.getElementsByTagName('form')[0],
input = document.createElement('textarea');
input.setAttribute('type', 'textarea');
input.setAttribute('name', 'item');
form.appendChild(input);
};
function contador()
{
var count = 0;
count++;
if(count == 10){
alert("QWERTY");
}
};
</script>
<form name="input" method="get">
<div class="ui-input-text">
<div data-role="navbar">
<button type="button" onclick="add_field(); contador();">ADD</button><br>
</div>
</div>
</form>
</body>
var count = 0;
out of functioncontador()
and it should already work. The problem is that you are putting thecount = 0
every time you called her– Miguel