Note that there are some explanatory texts on larger screens.

plurals
  1. POjs get element by id
    primarykey
    data
    text
    <p>HI all! I have a doubt. I need to get an element via its id. I know i can use document.getElementById() or jquery selector, but i don´t want to use jquery or any other library. The idea is to build a component using just js and no libraries.</p> <p>I got this situation, code generated by code:</p> <pre><code>&lt;div id="objprop"&gt; &lt;div id="prop-header"&gt;&lt;span&gt;Mi Ventana&lt;/span&gt;&lt;/div&gt; &lt;div id="prop_width" style="clear: both;"&gt; &lt;label style="margin-left: 7px; margin-bottom: 7px; float: left;"&gt;Width&lt;/label&gt; &lt;input type="text" style="float: right; margin-right: 7px; width: 70px;" id="width"&gt; &lt;/div&gt; &lt;div id="prop_height" style="clear: both;"&gt; &lt;label style="margin-left: 7px; margin-bottom: 7px; float: left;"&gt;Height&lt;/label&gt; &lt;input type="text" style="float: right; margin-right: 7px; width: 70px;" id="height"&gt; &lt;/div&gt; &lt;div id="prop_left" style="clear: both;"&gt; &lt;label style="margin-left: 7px; margin-bottom: 7px; float: left;"&gt;Left&lt;/label&gt; &lt;input type="text" style="float: right; margin-right: 7px; width: 70px;" id="left"&gt; &lt;/div&gt; &lt;div id="prop_top" style="clear: both;"&gt; &lt;label style="margin-left: 7px; margin-bottom: 7px; float: left;"&gt;Top&lt;/label&gt; &lt;input type="text" style="float: right; margin-right: 7px; width: 70px;" id="top"&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>so, let supose i want to set the value of input width id with. I´m not sure about using document.getElementById because may be other elements with same id in the html.</p> <p>well that is my doubt</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload