Click here to Skip to main content
14,668,320 members
Rate this:
Please Sign up or sign in to vote.
See more:
I am using this code to append div when i click or submit the button
<script type="text/javascript">
    $(document).ready(function() {
        var divProcessing = '<div><img src="/Images/processing.gif" alt="Processing.."/></div>';
        $(".btnProcessing").click(function() {
            $(this).hide().after().parent().append(divProcessing);
        });

    });
        
</script>

But some times when i click the submit button multiple divs(it displays multiple images) are added...

Pls tell why its append multiple divs..

any one say how to solve this problem............



And then i remove the div tag
<script type="text/javascript">
    $(document).ready(function() {
        var divProcessing = '<img src="/Images/processing.gif" alt="Processing.."/>';
        $(".btnProcessing").click(function() {
        $(this).hide().after().parent().append(divProcessing);
        });

        var prm = Sys.WebForms.PageRequestManager.getInstance();
        prm.add_endRequest(function() {
            $('.btnProcessing').click(function() {
            $(this).hide().after().parent().append(divProcessing);
            });
        });
    });
        
</script>


But now i have same issue but the image is added multiple times but horizontally..

If i am using div the image is added multiple time vertically..

why its occur...
Posted
Updated 28-Sep-12 1:56am
v5

Rate this:
Please Sign up or sign in to vote.

Solution 2

<script type="text/javascript">
    $(document).ready(function() {
        var divProcessing = '<div><img src="/Images/processing.gif" alt="Processing.."/></div>';
        $(".btnProcessing").click(function() {
                document.getElementById("div").appendChild(divProcessing);
        });
     });

</script>
   
Comments
saravana__ 27-Sep-12 5:01am
   
I think append() and appendChild() both are same difference is in java script we use appenChild() and jquery we use append()......

Tell me there is any difference between these two things..
Rate this:
Please Sign up or sign in to vote.

Solution 3

Try this..

<script type="text/javascript">
    $(document).ready(function() {
        var divProcessing = '<div><img src="/Images/processing.gif" alt="Processing.."/></div>';
        $(".btnProcessing").click(function() {
            $(this).hide().after().parent().html(divProcessing);
        });

    });

</script>
   
Comments
saravana__ 27-Sep-12 4:43am
   
Tell me why that issue occurs
saravana__ 27-Sep-12 4:45am
   
Its not working for me now also the above code add multiple divs
Rate this:
Please Sign up or sign in to vote.

Solution 4

working example:

http://jsfiddle.net/PSHWZ/12/[^]

bye
   
Rate this:
Please Sign up or sign in to vote.

Solution 1

   
Comments
saravana__ 27-Sep-12 5:08am
   
The above code is not working for me..
Why the processing image is displayed multiple times...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100