-3

Possible Duplicate:
jQuery onclick hide its parent element

I want to hide <li> when someone click on its child <a>. I used following jQuery code to perform the action but it is not working. Because if someone clicking on <a> that is twitter button it first calling class "twitter-follow-button". And it is not going for the jQuery action. jQuery Used:

$(document).ready(function(e) {
     $('.twitter-follow-button').click(function() {
            $(this).parent().hide();
     });
});

HTML Used:

 <ul>
   <li>
       <div>Something</div>
       <p>Something</p>
       <a href="https://twitter.com/'.$uname.'" class="twitter-follow-button">Follow </a>
   </li>
   <li>
       <div>Something</div>
       <p>Something</p>
       <a href="https://twitter.com/'.$uname.'" class="twitter-follow-button">Follow</a>
   </li>
</ul>
Community
  • 1
  • 1
Sunil Kumar
  • 1,389
  • 2
  • 15
  • 32
  • 1
    You asked this question already yesterday. If your problem isn't resolved, please modify your original question to include the updated information rather than asking an entirely new question – nbrooks Sep 02 '12 at 06:27

1 Answers1

1

It's not completely clear what problem you're trying to solve. If what you're trying to do is prevent the default action when clicking on the link and only do the hide, then you can do this:

$(document).ready(function(e) {
     $('.twitter-follow-button').click(function() {
            $(this).parent().hide();
            return false;   // prevent default action of the click
     });
});

Or, if you wanted to just delay the hide action for some period of time while other actions run you would do this:

$(document).ready(function(e) {
     $('.twitter-follow-button').click(function() {
            var self = this;
            setTimeout(function() {
                $(self).parent().hide();
            }, 1000);   // you pick the appropriate time here
     });
});
jfriend00
  • 683,504
  • 96
  • 985
  • 979
  • I want that on user click both actions will perform at same time one after one. For Example "twitter-follow-button" provides default action on click. After default action it will go for jQuery event that is a "hide parent". – Sunil Kumar Sep 02 '12 at 06:38
  • @SunilKumar - what code controls the other action? We can't really coordinate with another action unless we know what it is, what it does and where's the code that does it? You can delay the hide on a timer, but without knowing what the the other action is, I have no idea if that is sufficient. – jfriend00 Sep 02 '12 at 06:50