Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get another child element by classname of the parent div of a element that triggered a function
    primarykey
    data
    text
    <p>my problem sounds pretty simple. I have divs with no id and class specified like this</p> <pre><code>&lt;div style="position:relative; float:left"&gt; &lt;input type="text" onfocus="renderCalendar(event);" size="50" id="cal" name="cal"&gt; &lt;div class="wrappercal calwrapper"&gt; &lt;div class="yearmonth"&gt; &lt;table class="caltable"&gt;&lt;tbody&gt; &lt;tr&gt;&lt;th width="80%" scope="col" colspan="5"&gt; &lt;select class="dtcombo year" onchange="changeCalendar()"&gt; &lt;option value="2000"&gt;2000&lt;/option&gt; &lt;option value="2001"&gt;2001&lt;/option&gt; &lt;/select&gt;&amp;nbsp;&amp;nbsp; &lt;select onchange="changeCalendar()" class="dtcombo month"&gt; &lt;option value="1"&gt;1&lt;/option&gt; &lt;option value="2"&gt;2&lt;/option&gt; &lt;/select&gt;&lt;/th&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>There may be several similar divs in the page</p> <p>I have a javascript function</p> <pre><code>function renderCalendar(event){ var triggerer=event.target.id; // THIS WILL GIVE THE ID OF TEXTBOX THAT TRIGGERED THIS FUNCTION. $("#"+triggerer).parent().children(".wrappercal").children(".yearmonth").children(".caltable").children(".year").val(); //not working } </code></pre> <p>The nest follows like this </p> <pre><code> Parent Div &gt; wrappercal(div) &gt; yearmonth(div) &gt; caltable(table) &gt; year(select) </code></pre> <p>my problem is to get value of combo with class "year" of the parent div of textbox that triggered the function. </p> <p>Can anybody figure out where i went wrong? any suggestions?</p> <p>P.S. Please bear I m not good with dom elements.</p> <p>Thanks</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.
 

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