Hello friends, I have the following code: my error is as follows:
I'm doing a small application in which when you click "give me click" change color that works well because I select it with Jquery but when I want to add that part of the code to a function to be called through an onclick does not work, the other part of the code that resets the code to the original color does not work if I add it to a function
What do you think?
My Current Code:
$(document).ready(function () {
function resetar() {
$("#click").on('click', function () {
$("#texto").css("color", "blue");
});
}
resetar();
//Resetear el color al original
function resetar() {
$("#click").on('click', function () {
$("#texto").css("color", "black");
});
}
resetar();
});
.clase1 {
color:red;
}
.clase2 {
color:blue;
}
<!DOCTYPE html>
<html>
<head>
<title>App JQuery</title>
<meta charset="utf-8">
<script src="https://code.jquery.com/jquery-3.2.1.js"></script>
</head>
<body>
<h1>Introduccion a Jquery</h1>
<p>Hi i'm Sommer0123</p>
<p>Hi i'm Sommer0123</p>
<p>Hi i'm Sommer0123</p>
<p>Hi i'm Sommer0123</p>
<p id="texto">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur
sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<button id="click">Dame click</button>
<button onclick="resetar()">Restaurar todo</button>
<script src="js/main.js"></script>
</body>
</html>