Thread: jQuery Detect anchor click
View Single Post
Old 10-23-2012, 08:47 PM   PM User | #1
WolfShade
Regular Coder

 
Join Date: Apr 2012
Location: St. Louis, MO, USA
Posts: 960
Thanks: 7
Thanked 100 Times in 100 Posts
WolfShade is an unknown quantity at this point
Question Detect anchor click

Hello, everyone.

I'm dynamically populating a div after the page loads with some anchor tags. Basically, click one or more names in a multi-select and the names are added with anchor tags around them so that they can be removed by clicking the name.

I would like to set it so that when each name is clicked, if an alert message in a particular div is blank, then the div will display "Changes to this record have not been saved."

I'm not getting the function right. I've tried several different ways, I'll include two of them below. These are all coded within the $(document).ready()

Code:
$('.remLink a').each(function(e){
  e.preventDefault();
  $(this).click(function(){
    $('#chgWarning').html("Changes to this record have not been saved");
  });
});
Code:
$('.remLink a').each(function(e){
  e.preventDefault();
  $(this).live('click',function(){
    $('#chgWarning').html("Changes to this record have not been saved");
  });
});
How does one apply an event to an anchor that doesn't exist when the page loads?

Thank you,
__________________
^_^

If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
*
The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".
WolfShade is offline   Reply With Quote