Writing a simple alert code in Jquery

Recently I was fixing a bug in Mediawiki where I had to write the 
confirmation code. I had no idea working with Javascript, I did manage to 
get this one done. Here are a few basic steps on how to get this done.
I 'm having two parameters, title and description and I have to write a
confirmation code to check whether if some data has been changed. 

Declare the two variables title and desciprition.
         var title = 'input title';
         var description = 'input.description';

Check if the data has been changed in the title or description.

   this.$( 'input.title', '.description' ).change( checkEdited ); 
//Here checkEdited is a function to show an alert message.
//change is a selector that you use to chekc if any change has been

Write the function checkEdited.

        var checkEdited = function() {
             alert ('This is a test');

Make sure when you are writing the fucntion write the function before
you call the onChange fucntion.