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 .

3
  • 1
    When you want "up", you probably mean prepend as in it inserts at the top. Commented Dec 28, 2014 at 17:50
  • 1
    api.jquery.com/prepend Commented Dec 28, 2014 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()). Commented Dec 28, 2014 at 17:55

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.