php - in jquery comment system, use hide() and fadeIn('slow') to new comment only and not to all -


i have following jquery , php code used in comment system similar facebook.

user types comment , post it. use hide() , fadein('slow') in order comment posted appear in nice look. problem hide() , fadein('slow') works comments posted.

i want make work new comment posted each time. idea how correct code in order this?

<script>      $(document).ready(function(){                                $("#comment_process").click(function(){         if($("#comment_text").val() != ""){              $.post("comments.php?action=post", { comment: $("#comment_text").val() }, function(data) {                 $(".comments").html(data).hide().fadein('slow');                 $("#comment_text").val("");             });         }      });        });    </script>  <div class="comment_container">     <div class="comment_form">         <textarea id="comment_text" placeholder="type..."   style="font-size:11pt;  color:green;  resize:none ">    </textarea>         <input type="button" id="comment_process" value="post"/>     </div> </div>  <div class="comments">  <?php include_once("comments.php");?>  </div>     

comments.php used in order store , retreive comments database.

you assign data- attribute post , use

$('.comments[data-id=xxxxx]').hide().fadein(); 

to fade in.

you can assign many data- attributes want, have start data-, e.g. data-id, data-name, data-xxxxxx.

assigning attribute done this:

<div class="comments" data-id="xxxxx"> 

replace xxxxx want of course, e.g. new, 1, last...

as jquery selector limiting selection element attribute hide , fade in comment want, data- attributes can used loads of purposes.


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -