Note that there are some explanatory texts on larger screens.

plurals
  1. PORemoving classes of children
    primarykey
    data
    text
    <p>I would like to remove several class attributes from several child nodes under a dynamically created jQuery Accordion. I am having trouble getting my jQuery to function. This is what I have so far.</p> <pre><code>&lt;cfset index = 1&gt; &lt;cfloop query="qApp"&gt; &lt;h3 id="header_#index#"&gt;#ApplianceType#&lt;/h3&gt; &lt;div id="header_#index#"&gt; &lt;p&gt; &lt;!---- Serial Number ---&gt; &lt;div class="ctrlHolder invalid error" id="serial_#index#"&gt;&lt;label&gt;Serial Number&lt;/label&gt; &lt;cfinput type="text" name="app_#ApplianceTypeID#_ser" data-default-value="Enter Serial Number or Value" size="35" class="textInput required invalid error" id="serialinput_#index#" value="" /&gt; &lt;cfinput name="app_#ApplianceTypeID#_IDd" type="hidden" value="" /&gt; &lt;p class="formHint"&gt;field is required&lt;/p&gt; &lt;/div&gt; &lt;!--- Appliance ---&gt; &lt;div class="ctrlHolder invalid error" appl_#index#&gt;&lt;label&gt;Appliance&lt;/label&gt; &lt;cfinput name="app_#ApplianceTypeID#_app" data-default-value="Appliance" class="textInput required invalid error" id="applinput_#index#" value=""&gt; &lt;p class="formHint"&gt;Appliance is required&lt;/p&gt; &lt;/div&gt; &lt;!--- active ---&gt; &lt;div class="ctrlHolder" id="color_select"&gt; &lt;ul&gt; &lt;li&gt; &lt;label for="agreement"&gt; &lt;input type="checkbox" id="checkbox2_#index#" name="app_#ApplianceTypeID#_chk" style="width:50px"&gt; active &lt;/label&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/p&gt; &lt;/div&gt; &lt;cfset index = index + 1&gt; &lt;/cfloop&gt; &lt;script&gt; $('[id^=serial_]').each(function(){ $("#checkbox2_"+ id).change(function(){ if($(this).is(":checked")) { //separate id2 and checkbox sep_selid2 = this.id.split("_"); //separate id selid2 = sep_selid2[1]; $('H3#header_' + selid2).children().addClass("required"); } else { //separate id2 and checkbox sep_selid2 = this.id.split("_"); //separate id selid2 = sep_selid2[1]; $('div#header_' + selid2).children().removeClass("required"); $('div#header_' + selid2).children().removeClass("invalid"); $('div#header_' + selid2).children().removeClass("error"); } }); }); &lt;/script&gt; </code></pre> <p>So the desired functionality is when the user checks the "active" checkbox, the input fields have "required" added to the class. When the user unchecks the "active" checkbox "requried" , "error", and "invalid" are removed. Please let me know if I confused you and ask any questions. 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.
    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