Function gets called. A JavaScript function is a block of code designed to perform a particular task.
A JavaScript function is executed when "something" invokes it (calls it).
function displays_Five() {
window.alert("Five");
}
function displays_Four() {
window.alert("Four");
}
function displays_Three() {
window.alert("Three");
}
function displays_Two() {
window.alert("Two");
}
function displays_One() {
window.alert("One");
}
Here's one way:
window.alert("Five");
window.alert("Four");
window.alert("Three");
window.alert("Two");
window.alert("One");
Now if you really want to create a wrapper function:
function myAlert(str) {
window.alert(str);
}
myAlert("Five");
myAlert("Four");
myAlert("Three");
myAlert("Two");
myAlert("One");
function myAlert(str) { window.alert(str); } myAlert("Five"); myAlert("Four"); myAlert("Three"); myAlert("Two"); myAlert("One");
function showAlert(contents) {
alert(contents);
}
But why not just use the alert function itself?
simple as:
function displayAlert(text) {
alert(text);
}
// Prompt from client
var input = prompt('What you want?');
// Make sure input is not empty (NULL) then display client input
if(input) displayAlert(input);
// Or display static text
displayAlert('Well Done.')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.