0

I have code jquery working fine with me ,

the problem is when I insert data and selected its append down then down then down :) I wont append up of last append data

here is code:

<script>
    $(function(){
        $('#categorie-form').submit(function(){
            $.post("categorie.php?type=categorie",$('#categorie-form').serialize(),function(categorie){
                $("#showCategorie").append(categorie);
                $("[name=categories]").val("");
            });
            return false;
        });
    });
</script>

<div id="showCategorie" ></div>

i hope answer simple .

  • 1
    When you want "up", you probably mean `prepend` as in it inserts at the top. – adeneo Dec 28 '14 at 17:50
  • 1
    http://api.jquery.com/prepend/ – adeneo Dec 28 '14 at 17:50
  • From `append()` DOC: `The .append() method inserts the specified content as the last child of each element in the jQuery collection (To insert it as the first child, use .prepend()).` – A. Wolff Dec 28 '14 at 17:55

1 Answers1

1

Try replacing $("#showCategorie").append(categorie); with $("#showCategorie").prepend(categorie);

See .append(), prepend(), .after() and .before() for a clear explanation of different functions to add things to the DOM.

Community
  • 1
  • 1
mickzer
  • 5,958
  • 5
  • 34
  • 57