You must Sign In to post a response.
  • Category: JQuery

    How to remove div inside another div using jquery

    Hi,

    In my application iam loading another webpage inside a divtag like below

    $("#ContentPlaceHolder1_txtsource").click(function (e) {
    e.preventDefault();
    $('#divdistance').show();
    $('#divdistance').html('<object data="http://www.xyz.asp" />');
    });

    this is working fine

    my requirement is to remove a particular div of http://www.xyz.asp

    like this

    $("divdistance").children(".navbar-header").remove();
    but not working

    this should be after loading of http://www.xyz.asp

    how it is possible


    Regards

    Baiju
  • #766955
    You can hide the div by even syntax of Javascript in Jquery method like this code
    Javascript


    document.getEelementById('divdistance').style.visibility="hidden"

    Jquery

    $('#divdistance').fadeOut();
    $('#divdistance').slideUp();
    $('#divdistance').hide();

    SRI RAMA PHANI BHUSHAN KAMBHAMPATI

  • #766958
    if you want to remove child DIV then you can use 'children.remove' method , it helps you to target direct children of body. Then use "a:first" as the selector to target the first <a> element.

    $("body").children("a:first").remove();

    Thanks
    Koolprasd2003
    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • #766968
    Hi,
    Try this:
    $('#divdistance div').remove();
    Or
    $('#divdistance').find('div').remove();
    Or
    $( '#divdistance' ).remove( '.divClassYouWantToRemove');
    Or
    $( '#divdistance' ).remove( ':contains('stringFromDiv')');

  • #766972
    You can try to remove using the remove attribute. You can remove the inner div by finding it.
    You can try the following to remove it from your inner div
    $('#divdistance').find('div').remove();

    By Nathan
    Direction is important than speed

  • #766985
    Hi

    try this code



    <div id="parentDiv">
    <div>1</div>
    <div>2</div>
    <div>3</div>
    <div>4</div>
    <div>5</div>
    </div>

    $("#parentDiv").empty();



    <html lang="en">
    <head>
    <meta charset="utf-8">
    <title>remove demo</title>
    <style>
    p {
    background: yellow;
    margin: 6px 0;
    }
    </style>
    <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
    </head>
    <body>

    <p>Hello</p>
    how are
    <p>you?</p>
    <button>Call remove() on paragraphs</button>

    <script>
    $( "button" ).click(function() {
    $( "p" ).remove();
    });
    </script>

    </body>
    </html>




    step2

    <div class="chartsbar" style="position: absolute; bottom: 0px; left: 27.28%; display: none; height: 0%;
    background-color: rgb(7, 134, 205); color: rgb(255, 255, 255); width: 0.9730252100840335%; text-align: left;
    " rel="0" title="09-09-2012 - 0 (0%)">



    $('.chartsbar div').remove();


    $('.chartsbar div:first').remove();




    Refer this url



    "api.jquery.com/remove/"


    Name : Dotnet Developer-2015
    Email Id : kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.


  • Sign In to post your comments