JavaUser
JavaUser

Reputation: 26324

show and hide a div and insert after some other div

I am having a div with style display none and later I am setting this to null. And I am adding after some other div . But this is shown. Can you help ?

$("#SecondDiv").css("display : null");
$("#SecondDiv").insertAfter($("#FirstDiv"));


    <div class="note note-warning" id="SecondtDiv" style="display: none">
        <div class="block-warning">
            <h4 class="block"> <i class="demo-icon icon-attention-1 fa"></i> Error! </h4>
            <p>Settings is not updated</p>
        </div>
    </div>    

    <div class="table-responsive" id="FirstDiv">

Thanks

Upvotes: 1

Views: 191

Answers (2)

Iwnnay
Iwnnay

Reputation: 2008

This is not valid CSS:

$("#SecondDiv").css("display : null");

So what's happening is that the display style is defaulting to 'inline'; You're gonna want to switch this to :

$("#SecondDiv").css("display", "none");

Upvotes: 2

Reda
Reda

Reputation: 1369

Instead of using .css("display : null") which is already incorrect usage of the function but try using .show() like this:

$("#SecondDiv").show();

Also, the id of the div you are trying to reference in the markup is misspelt I assume as SecondtDiv when it should be SecondDiv.

Upvotes: 3

Related Questions