JavaScript getElementById is not working for the div which is inside of tabset

this is my html

<div>
<h1 class="main-header logic-head  av-settings-head"></h1>
<div class="col-xs-12 col-xs-12 col-lg-12 tabcontent" >
    <form class="form-horizontal formtext col-xs-12 col-sm-10 col-lg-10 row">
        <div class="form-group">
            <div class="col-xs-12 col-sm-5 col-lg-3 paddnone">
                <label class="control-label">Name</label>
            </div>

            <div class="col-sm-5">
                <input id="NewobjectName" type="text" class="form-control" />
            </div>
        </div>
        <div class="form-group">
            <div class="col-xs-12 col-sm-5 col-lg-3 paddnone">
                <label class="control-label">Description</label>
            </div>
            <div class="col-xs-12 col-sm-5 col-lg-5 paddnone">
                <textarea id="objectDescription" rows="3" class="form-control"></textarea>
            </div>
        </div>
        <div class="form-group">
            <div class="col-xs-12 col-sm-5 col-lg-3 paddnone">
                <label class="control-label">Type</label>
            </div>
            <div class="col-xs-12 col-sm-5 col-lg-5 paddnone">
                <select class="form-control">
                    <option>M</option>
                    <option>C</option>
                    <option>CM</option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <div class="col-xs-12 col-sm-5 col-lg-3 paddnone">
                <label class="control-label">IsActive</label>
            </div>

            <div class="col-sm-5">
                <input type="checkbox" checked="true" />
            </div>
        </div>
        <div class="form-group">
            <div class="col-xs-12 col-sm-5 col-lg-3 paddnone">
                <label class="control-label">
                </label>
            </div>
            <div class="clearfix"></div>             
            <!-- Groups Area Tables Start -->
            <div class="row">

                <div role="tabpanel" class="tab_bg">
                    <!-- Nav tabs -->

                    <div tabset justified="true" ng-if="clientScript.specification=='commonSpecific'">

                        <div tab heading="ClientScript">
                            <div class="tab-content pad25 users-area">
                                <div role="tabpanel" class="tab-pane mart15 active" id="objectPermissions">
                                    <div class="form-group">
                                        <div class="col-xs-12 col-sm-5 col-lg-3 paddnone">
                                            <label class="control-label">Javascript Type</label>
                                        </div>
                                        <div class="col-xs-12 col-sm-5 col-lg-5 paddnone">
                                            <select class="form-control" ng-change="onEventChange(script.event)" ng-options="obj.eventName as obj.label for obj in events"
                                                    ng-model="script.event">
                                                <option value="">-select event-</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="method-tab" id="method-tab">
                                        <div class="row form-group btnbg">
                                            <div class=" col-xs-12 col-sm-6 col-lg-12">
                                                <button class="btn btn-primary pull-right">ADD +</button>
                                                <div class="clearfix"></div>
                                            </div>
                                        </div>
                                        <div class="col-xs-12 col-sm-12 col-lg-12 well pad0">
                                            <div class="tabbable tabs-left">
                                                <ul class="nav nav-tabs method-right">
                                                    <li class="active"><i></i><a target='_blank' href="#name" data-toggle="tab">Script 1</a></li>
                                                    <li class=""><i></i><a data-toggle="tab" target='_blank' href="#group-2">Script 2</a></li>
                                                    <li class=""><i></i><a target='_blank' href="#group-3" data-toggle="tab">Script 3</a></li>
                                                    <li class=""><i></i><a target='_blank' href="#group-4" data-toggle="tab">Script 4</a></li>
                                                </ul>
                                                <div class="tab-content content-left">
                                                    <div class="tab-pane col-xs-12 col-sm-8 col-lg-12 pad0 marl19 active" id="name">
                                                        <div class="col-lg-12">
                                                            <h4>Javascript Editor</h4>
                                                        </div>
                                                        <div class="clearfix"></div>
                                                        <div class="col-lg-12">
                                                            <div class="panel panel-default">

                                                                <div class="panel-body min-height">
                                                                    <div id="editor">
                                                            function foo(items) {
                                                                var i;
                                                                for (i = 0; i &lt; items.length; i++) {
                                                                    alert("Ace Rocks " + items[i]);
                                                                }
                                                            }
                                                            </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="clearfix"></div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="row form-group btnbg">
                                            <div class=" col-xs-12 col-sm-6 col-lg-12">
                                                <button class="btn btn-primary pull-right">SAVE</button>
                                                <div class="clearfix"></div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <button id="saveObject" class="btn btn-primary" ng-click="save()">
                                    Validate
                                </button>

                            </div>

                        </div>
                        <div tab heading="SQL">

                        </div>
                        <div tab heading="HTML">

                        </div>
                    </div>                    
                </div>
            </div>
            <div class="col-xs-12 col-sm-9 col-lg-7  btnbg">
                <button id="saveObject" class="btn btn-primary " ng-click="save()">
                    SAVE
                </button>
            </div>
        </div>
    </form>
</div>

and i am finding the element by id which is inside of tabset and that id name is "editor" but it is giving null

and my .js code is var element=document.getElementById("editor");

the div with id "editor" is inside of tabset so i think that would be reason why it couldn't find it...so what would be the alternate method to handle this?

Answer:1

your code is working properly

var element =  document.getElementById("editor");
snippet.log(element)
snippet.log(element.innerHTML)
<script src="http://tjcrowder.github.io/simple-snippets-console/snippet.js"></script>
<div>
  <h1 class="main-header logic-head  av-settings-head"></h1>
  <div class="col-xs-12 col-xs-12 col-lg-12 tabcontent">
    <form class="form-horizontal formtext col-xs-12 col-sm-10 col-lg-10 row">
      <div class="form-group">
        <div class="col-xs-12 col-sm-5 col-lg-3 paddnone">
          <label class="control-label">Name</label>
        </div>

        <div class="col-sm-5">
          <input id="NewobjectName" type="text" class="form-control" />
        </div>
      </div>
      <div class="form-group">
        <div class="col-xs-12 col-sm-5 col-lg-3 paddnone">
          <label class="control-label">Description</label>
        </div>
        <div class="col-xs-12 col-sm-5 col-lg-5 paddnone">
          <textarea id="objectDescription" rows="3" class="form-control"></textarea>
        </div>
      </div>
      <div class="form-group">
        <div class="col-xs-12 col-sm-5 col-lg-3 paddnone">
          <label class="control-label">Type</label>
        </div>
        <div class="col-xs-12 col-sm-5 col-lg-5 paddnone">
          <select class="form-control">
            <option>M</option>
            <option>C</option>
            <option>CM</option>
          </select>
        </div>
      </div>
      <div class="form-group">
        <div class="col-xs-12 col-sm-5 col-lg-3 paddnone">
          <label class="control-label">IsActive</label>
        </div>

        <div class="col-sm-5">
          <input type="checkbox" checked="true" />
        </div>
      </div>
      <div class="form-group">
        <div class="col-xs-12 col-sm-5 col-lg-3 paddnone">
          <label class="control-label">
          </label>
        </div>
        <div class="clearfix"></div>
        <!-- Groups Area Tables Start -->
        <div class="row">

          <div role="tabpanel" class="tab_bg">
            <!-- Nav tabs -->

            <div tabset justified="true" ng-if="clientScript.specification=='commonSpecific'">

              <div tab heading="Scocu ClientScript">
                <div class="tab-content pad25 users-area">
                  <div role="tabpanel" class="tab-pane mart15 active" id="objectPermissions">
                    <div class="form-group">
                      <div class="col-xs-12 col-sm-5 col-lg-3 paddnone">
                        <label class="control-label">Javascript Type</label>
                      </div>
                      <div class="col-xs-12 col-sm-5 col-lg-5 paddnone">
                        <select class="form-control" ng-change="onEventChange(script.event)" ng-options="obj.eventName as obj.label for obj in events" ng-model="script.event">
                          <option value="">-select event-</option>
                        </select>
                      </div>
                    </div>
                    <div class="method-tab" id="method-tab">
                      <div class="row form-group btnbg">
                        <div class=" col-xs-12 col-sm-6 col-lg-12">
                          <button class="btn btn-primary pull-right">ADD +</button>
                          <div class="clearfix"></div>
                        </div>
                      </div>
                      <div class="col-xs-12 col-sm-12 col-lg-12 well pad0">
                        <div class="tabbable tabs-left">
                          <ul class="nav nav-tabs method-right">
                            <li class="active"><i></i><a target='_blank' href="#name" data-toggle="tab">Script 1</a>
                            </li>
                            <li class=""><i></i><a data-toggle="tab" target='_blank' href="#group-2">Script 2</a>
                            </li>
                            <li class=""><i></i><a target='_blank' href="#group-3" data-toggle="tab">Script 3</a>
                            </li>
                            <li class=""><i></i><a target='_blank' href="#group-4" data-toggle="tab">Script 4</a>
                            </li>
                          </ul>
                          <div class="tab-content content-left">
                            <div class="tab-pane col-xs-12 col-sm-8 col-lg-12 pad0 marl19 active" id="name">
                              <div class="col-lg-12">
                                <h4>Javascript Editor</h4>
                              </div>
                              <div class="clearfix"></div>
                              <div class="col-lg-12">
                                <div class="panel panel-default">

                                  <div class="panel-body min-height">
                                    <div id="editor">
                                      function foo(items) { var i; for (i = 0; i &lt; items.length; i++) { alert("Ace Rocks " + items[i]); } }
                                    </div>
                                  </div>
                                </div>
                              </div>
                              <div class="clearfix"></div>
                            </div>
                          </div>
                        </div>
                      </div>
                      <div class="row form-group btnbg">
                        <div class=" col-xs-12 col-sm-6 col-lg-12">
                          <button class="btn btn-primary pull-right">SAVE</button>
                          <div class="clearfix"></div>
                        </div>
                      </div>
                    </div>
                  </div>
                  <button id="saveObject" class="btn btn-primary" ng-click="save()">
                    Validate
                  </button>

                </div>

              </div>
              <div tab heading="Scocu SQL">

              </div>
              <div tab heading="Scocu HTML">

              </div>
            </div>
          </div>
        </div>
        <div class="col-xs-12 col-sm-9 col-lg-7  btnbg">
          <button id="saveObject" class="btn btn-primary " ng-click="save()">
            SAVE
          </button>
        </div>
      </div>
    </form>
  </div>
Answer:2

I have created a sample typeorm project using the typeorm cli which has ormconfig.json by default: { "type": "postgres", "host": "localhost", "port": 5432, "username": "postgres", "...

I have created a sample typeorm project using the typeorm cli which has ormconfig.json by default: { "type": "postgres", "host": "localhost", "port": 5432, "username": "postgres", "...

I am using html2canvas.js to create a <canvas> image from a div on a page. What I'd like to do is send the rendered base64 image to a cfc via ajax so I can actually save the image to a folder on ...

I am using html2canvas.js to create a <canvas> image from a div on a page. What I'd like to do is send the rendered base64 image to a cfc via ajax so I can actually save the image to a folder on ...

  1. send base64 image to server
  2. send base64 image to web api c#
  3. send base64 image in email
  4. send base64 image to server python
  5. send base64 image postman
  6. send base64 image to server c#
  7. send base64 image in email java
  8. send base64 image to server angular 4
  9. send base64 image in json
  10. send base64 image in url
  11. send base64 image to server php
  12. send base64 image to server android
  13. send base64 image to server nodejs
  14. send base64 image to web api
  15. send base64 image in email c#
  16. send base64 image to server javascript
  17. send base64 image to server android volley
  18. send base64 image in email php
  19. send base64 image ajax
  20. send base64 image nodejs

I have the following setup where a custom checkmark is added to style the radio buttons. but it also adds that checkmark to the text type inputs. var changed =function(){ Array.from(...

I have the following setup where a custom checkmark is added to style the radio buttons. but it also adds that checkmark to the text type inputs. var changed =function(){ Array.from(...

I need to take some non-trivial javascript and ensure that all code paths have code that is valid. For example: var num = 1; if (num == 2) { badFunctionName(); } and I need to do this from C#. ...

I need to take some non-trivial javascript and ensure that all code paths have code that is valid. For example: var num = 1; if (num == 2) { badFunctionName(); } and I need to do this from C#. ...

  1. verify javascript code online
  2. verify javascript code
  3. check javascript code
  4. check javascript code online
  5. check javascript code for browser compatibility
  6. check javascript code for errors
  7. check javascript code for errors online
  8. check javascript code syntax
  9. check javascript code quality
  10. check javascript code style
  11. verification code javascript
  12. javascript check code syntax online
  13. javascript check code execution time
  14. javascript check code coverage
  15. age verification javascript code
  16. email verification javascript code