what is .alert()

Sometimes you need to go back to basics and use the .alert() function is jQuery to see what the hell a variable is or check if your JavaScript is actually working at all?! Probably one of the most underated functions but certainly the most used is jquery.Alert(). Also known as a jQuery command box or system popup window that contains text information displayed to the user.

How to use .alert()

//when the webpage is loaded
jQuery(document).ready(function($) {
	alert("js is working");

Other variations:

// or
// also try

If the last one doesn’t work (it should alert ‘HTMLElement’, depending on the browser) then jQuery is not working, you might need to check your imports are correct or check for errors in your JavaScript files.

Sam Deering is a Front-end Web Developer who specialises in JavaScript & jQuery. Sam is driven and passionate about sharing his knowledge to educate others.

Free Guide:

How to Choose the Right Charting Library for Your Application

How do you make sure that the charting library you choose has everything you need? Sign up to receive this detailed guide from FusionCharts, which explores all the factors you need to consider before making the decision.

No Reader comments

Learn JavaScript for free!
Free course: Introduction to JavaScript

Yours when you take up a free 14-day SitePoint Premium trial.