Note that there are some explanatory texts on larger screens.

plurals
  1. POPass dynamic id's for javascript
    primarykey
    data
    text
    <p>I want to open a group with HTML-Elements when I click on a checkbox. It works fine for one group (because then i only have one id). But if I have more groups, each group has a dynamic id (for div-tag and input-tag). This is my HTML-Code:</p> <pre><code>&lt;div style="line-height: 1.7em; background-color: #eee;"&gt; &lt;span style="padding-left: 8px; color: #eb8f00; font-size: 1.1em; font-weight: bold; font-family: 'Trebuchet MS', Verdana, Helvetica, Sans-Serif;"&gt; &lt;input style="vertical-align: middle;" id="@currentElement.sGroupId" type="checkbox" name="@currentElement.sGroupId" /&gt; &lt;label for="@currentElement.sGroupId"&gt;@currentElement.sGroupName&lt;/label&gt; &lt;/span&gt; &lt;/div&gt; &lt;div style="background-color: #eee;" class="@currentElement.sGroupName"&gt; &lt;!-- Dynamic content --&gt; &lt;/div&gt; </code></pre> <p>Now i have those string which are dynamic due to my foreach loop.</p> <p>@currentElement.sGroupId looks like 'idgr_12' (only the number changes)<br> @currentElement.sGroupName is the name of the 'Group' which I want to open (the whole name changes with every loop)</p> <p>This is my Javascript Code:</p> <pre><code>$(function () { $("id from div").hide(); $("id from input").change(function () { var $this = $(this); if ($this.is(":checked")) { $("id from div").show(250); } else { $("id from div").hide(250); } }); }); </code></pre> <p>Now i get for example three groups, each with a checkbox. But when I click on one checkbox each group expands. How i get these dynamic id's in my javascript method, so that only the group with the activated checkbox expands?</p>
    singulars
    1. This table or related slice is empty.
    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