Note that there are some explanatory texts on larger screens.

plurals
  1. POjquery next() to skip label
    primarykey
    data
    text
    <p>I have a generic function that populates a 2nd field from a first. In cases where there is a label, it creates a problem, as the label is the </p> <pre><code>next() </code></pre> <p>element.</p> <p>So, i end up with:</p> <pre><code>function buildoptions(el){ var element = el.id; var $flda = $('#'+element); var $fldb = $flda.next().next(); //double here to skip the label ..... } </code></pre> <p>but of course, i have a few fields that don't have labels so this breaks...</p> <p>I was thinking</p> <pre><code>var $fldb = $flda.next().not(label); </code></pre> <p>would work, but it does not. It actually throws an error </p> <pre><code>Error: 'label' is undefined </code></pre> <p>ideas?</p> <p>HTML looks like:</p> <pre><code>&lt;label for="inp_29"&gt;Select drives next&lt;/label&gt; &lt;select id="inp_29" name="driver1" onchange="buildoptions(this);"&gt; &lt;option value="" selected="selected"&gt;Select&lt;/option&gt; &lt;option value="option1"&gt;option1&lt;/option&gt; &lt;option value="option2"&gt;option2&lt;/option&gt; &lt;/select&gt; &lt;!--* SOMETIMES OPTIONAL LABEL*--&gt; &lt;label for="inp_30"&gt;No default options&lt;/label&gt; &lt;!--* END SOMETIMES OPTIONAL LABEL*--&gt; &lt;select id="inp_30" name="filler1"&gt; &lt;option value="Select Driver First"&gt;Select Driver First&lt;/option&gt; &lt;/select&gt; </code></pre> <p>I also have a tabular case:</p> <pre><code>&lt;TR id="dynrow_table35_1" class=""&gt; &lt;TD class="odd"&gt; &lt;LABEL for="inp_331"&gt;absel&lt;/LABEL&gt; &lt;SELECT id="inp_331" onchange="buildoptions(this);" name="absel_1"&gt; &lt;OPTION value=""&gt;Select&lt;/OPTION&gt; &lt;OPTION value="option1"&gt;option1&lt;/OPTION&gt; &lt;OPTION value="option2"&gt;option2&lt;/OPTION&gt; &lt;/SELECT&gt;&lt;/TD&gt; &lt;TD class="odd"&gt;&lt;LABEL for="inp_341"&gt;No default options&lt;/LABEL&gt; &lt;SELECT id="inp_341" name="abfil1"&gt; &lt;OPTION value="Select Driver First"&gt;Select Driver First&lt;/OPTION&gt; &lt;/SELECT&gt; &lt;/TD&gt; &lt;/TR&gt; </code></pre> <p>id's are dynamicly built and i will never know their actual ID.</p>
    singulars
    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