Link to home
Start Free TrialLog in
Avatar of Seven price
Seven priceFlag for United States of America

asked on

jquery onclick detect id value

Hi, I am trying to for example alert a popup if and id has a value. so far the code does a popup with the id value and and blank popup if it has no value.  I want to make sure there is not popup if there is no id value.

 $(document).ready(function () {
         $("a").click(function () {
            
             if ($('a').val) {
                 alert(this.id);
             }
             else {
                 'nothing happen'
             }
           
     });
     });

 <a href="#" id="33" class="ui-link-inherit" >link1</a>

 <a href="#" id="34" class="ui-link-inherit" >link2</a>

 <a href="#"  class="ui-link-inherit" >link no id1</a>

 <a href="#"  class="ui-link-inherit" >link no id2</a>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Gary
Gary
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Seven price

ASKER

Great thanks