Click here to Skip to main content
15,886,708 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using this code to append div when i click or submit the button
JavaScript
<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
JavaScript
<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

XML
<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>
 
Share this answer
 
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..
Try this..

XML
<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>
 
Share this answer
 
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
working example:

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

bye
 
Share this answer
 
 
Share this answer
 
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, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900