-2

I have a div which is hidden in a form (class="hide"), when I click a button then that div be shown by removing the class "hide". That div is having a label and a button . The label is not shown when the "hide" class is removed dynamically. But the buttons are shown. Only the label is missing. Let me know the problem here.

<div id="UpdateDiv" class="hide" class="col-lg-12">
  <div align="right" style="margin:10px;">
    <label id='UpdateSuccess'>Update Successful</label>
    <a class="btn btn-primary btn-sm" style="margin-left:10px; width:100px;">
      <i class="demo-icon icon-cw-1 fa-fw" style="font-size:1.3em;"> </i> Update
    </a>
    <button type="button" class="btn btn-primary btn-sm" style="width:120px; border:0px ">Cancel</button>
  </div>
</div>


$("#UpdateDiv").removeClass("hide");

Thanks.

JavaUser
  • 25,542
  • 46
  • 113
  • 139

2 Answers2

2

I think you messed up your quotes:

<div id="UpdateDiv" class="hide" class="col-lg-12">
    <div align="right" style="margin:10px;">
        <label id="UpdateSuccess">Update Successful</label>
        <a class="btn btn-primary btn-sm" style="margin-left:10px; width:100px;">
            <i class="demo-icon icon-cw-1 fa-fw" style="font-size:1.3em;"> </i> Update
        </a>
        <button type="button" id="Cancel_{{hubName}}" class="btn btn-primary btn-sm" style="width:120px; border:0px"> Cancel</button>
    </div>
 </div>
Jonas Grumann
  • 10,438
  • 2
  • 22
  • 40
  • Although `' ">` is wrong in the original code, attributes in HTML5 do not necessarily need quotes (only if you use a space like in classnames than quotation is necessary) – Roko C. Buljan Aug 23 '16 at 07:25
  • 2
    Yes I know. I added them since this looks like a beginner code to me, so I want to get him used to it in order to not have the space problem in the future. – Jonas Grumann Aug 23 '16 at 07:27
  • Yes, best. Mine was more like a follow-up to your answer – Roko C. Buljan Aug 23 '16 at 07:27
  • Oh ok, you are right though, thanks for pointing that out. Now he'll be double aware of it in the future ;) – Jonas Grumann Aug 23 '16 at 07:28
0

Your html is wrong. I have fixed this here.

$("#UpdateDiv").removeClass("hide");
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id=UpdateDiv class="hide" class="col-lg-12">
  <div align="right" style="margin:10px;">
    <label id='UpdateSuccess'>Update Successful</label>
    <a class="btn btn-primary btn-sm" style="margin-left:10px; width:100px;">
      <i class="demo-icon icon-cw-1 fa-fw" style="font-size:1.3em;"> </i> Update
    </a>
    <button type="button" id=Cancel_{{hubName}} class="btn btn-primary btn-sm" style="width:120px; border:0px ">Cancel</button>
  </div>
</div>
Roko C. Buljan
  • 196,159
  • 39
  • 305
  • 313
Rajan Goswami
  • 769
  • 1
  • 5
  • 17