Display alert based on user's selection with radio buttons

Display alert based on user's selection with radio buttons

Hi,

I have been having problems with my jQuery function which should display the appropriate message when the user selects a certain radio button. I am trying to achieve this using a conditional statement. When the user selects the first radio button they should see the message "test45", if they select the second radio button, they will see the message "test1". 
Here is my code:

  1. function test(){

  2. if ($("input:checked")){
  3. window.alert("test45");
  4. }

  5. else if ($("input:checked")){
  6. window.alert("test1");
  7. }

  8. }