JavaScript Definir função
function nameFunction(parameters) {
document.write("function script")
}
Rick Astley
function nameFunction(parameters) {
document.write("function script")
}
<div class="alert alert-warning alert-dismissible fade show" role="alert">
<strong>Holy guacamole!</strong> You should check in on some of those fields below.
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
var x = myFunction(10, 10); // Function is called, return value will end up in x
function myFunction(a, b) {
return a * b; // Function returns the product of a and b
}
$('a.button').click(function(){
if (condition == 'true'){
function1(someVariable, function() {
function2(someOtherVariable);
});
}
else {
doThis(someVariable);
}
});
function function1(param, callback) {
...do stuff
callback();
}
function findMin(a, b, c) {
if (a < b ) {
return a;
} else {
return c;
}
} else if (b < a) {
if (b < c) {
return b;
} else {
return c;
}
} else {
return c;
}
}
function nameOfFunction () {
// function body
}