我能够在JSFiddle中获得一段代码,但是当我将其复制到Drupal的js文件中时,它不会: HTML
<form class="webform-client-form webform-client-form-288" action="/node/288" method="post" id="webform-client-form-288" accept-charset="UTF-8"><div><div class="form-item webform-component webform-component-radios webform-component--beans">
<label for="edit-submitted-beans">Beans </label>
<div id="edit-submitted-beans" class="form-radios thumb"><div class="form-item form-type-radio form-item-submitted-beans">
<input class="thumb form-radio" type="radio" id="edit-submitted-beans-1" name="submitted[beans]" value="<a href="#">Black Valentine" /> <label class="option" for="edit-submitted-beans-1">Black Valentine<img src="https://chplnj.org/sites/all/themes/newbartik/images/Seeds/Bean_Black Valentine_Seed Savers.png" alt="" class="beans"></a> </label>
</div>
</div>
</div>
<div class="form-item webform-component webform-component-checkboxes webform-component--beans2">
<label for="edit-submitted-beans2">Blue Lake Pole Territorial </label>
<div id="edit-submitted-beans2" class="form-checkboxes thumb"><div class="form-item form-type-checkbox form-item-submitted-beans2-<a-href="#">Blue-Lake-Pole-Territorial">
<input class="thumb form-checkbox" type="checkbox" id="edit-submitted-beans2-1" name="submitted[beans2][<a href="#">Blue Lake Pole Territorial]" value="<a href="#">Blue Lake Pole Territorial" /> <label class="option" for="edit-submitted-beans2-1">Blue Lake Pole Territorial<img src="https://chplnj.org/sites/all/themes/newbartik/images/Seeds/Bean_Blue Lake Pole_Territorial Seeds.png" alt="" class="beans2"></a> </label>
</div>
</div>
</div>
<input class="webform-submit button-primary form-submit" type="submit" name="op" value="Submit" /></div></div></form> </div>
JS:
(function ($) {
var checkBoxes = $('.thumb');
checkBoxes.change(function () {
$('.webform-submit').prop('disabled', checkBoxes.filter(':checked').length >1);
});
$('.thumb').change();
})(jQuery);
我的.info文件中的脚本正确无误,例如scripts [] = buttontoggle.js
同样,这在JSFiddle中有效,但是当我尝试将其用于Webforms放入Drupal时无效。