10 examples of 'jquery disable select' in JavaScript

Every line of 'jquery disable select' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
49function disableSelect(chkbox) {
50 var sibling = chkbox;
51 while (sibling != null) {
52 if (sibling.nodeType == 1 && sibling.tagName.toLowerCase() == "select") {
53 $(sibling).prop('disabled', !chkbox.checked);
54 }
55 sibling = sibling.previousSibling;
56 }
57}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

229function enableSelectOption($option) {
230
231 // given an already disabled select option, enable it
232
233 $option.removeClass(options.optionDisabledClass)
234 .attr("disabled", false);
235
236 if(options.hideWhenAdded) $option.show();
237 if($.browser.msie) $select.hide().show(); // this forces IE to update display
238}
67function select(selectAll) {
68 var lists = $('.deplistContent.active ul');
69 for (var i = 0; i < lists.length; i++) {
70 var checks = lists[i].getElementsByTagName('input');
71 for (var j = 0; j < checks.length; j++) {
72 if (checks[j].id === 'common') {
73 continue;
74 }
75 checks[j].checked = selectAll;
76 }
77 var lis = lists[i].getElementsByTagName('li');
78 for (var n = 0; n < checks.length; n++) {
79 if (checks[n].id === 'common') {
80 continue;
81 }
82 lis[n].className = (selectAll) ? 'active' : '';
83 }
84 }
85 updateCommand();
86 return false;
87}
61function clearSelectFilter(select) {
62 select.children('option').removeAttr('disabled');
63 initializeSelect(select);
64}
179function setSelectState(val) {
180
181 if (isBooleanSelect) {
182 if (val) {
183 mdcSelect.selectedIndex = 1;
184 mdcList.selectedIndex = 1;
185 $this.find('.mdc-select__icon').attr('src', myMdwHelper.getValueFromData(data.imageTrue, ''))
186 } else {
187 mdcSelect.selectedIndex = 0;
188 mdcList.selectedIndex = 0;
189 $this.find('.mdc-select__icon').attr('src', myMdwHelper.getValueFromData(data.image, ''))
190 }
191 } else {
192 for (var i = 0; i <= data.values; i++) {
193 if (val.toString() === myMdwHelper.getValueFromData(data.attr('value' + i), '').toString()) {
194 mdcSelect.selectedIndex = i;
195 mdcList.selectedIndex = i;
196 $this.find('.mdc-select__icon').attr('src', myMdwHelper.getValueFromData(data.attr('menuIcon' + i), ''))
197
198 break;
199 }
200 }
201 }
202};
4function enableSelectBoxes(){
5 $('div.selectBox').each(function(){
6 $(this).children('span.selected').html(
7 $(this).children('div.selectOptions').children('span.selectOption:first').html()
8 );
9 $(this).attr('value',$(this).children('div.selectOptions').children('span.selectOption:first').attr('value'));
10
11 $(this).children('span.selected,span.selectArrow').click(function(){
12 if($(this).parent().children('div.selectOptions').css('display') == 'none')
13 {
14 $(this).parent().children('div.selectOptions').css('display','block');
15 }
16 else
17 {
18 $(this).parent().children('div.selectOptions').css('display','none');
19 }
20 });
21
22 $(this).find('span.selectOption').click(function(){
23 $(this).parent().css('display','none');
24 $(this).closest('div.selectBox').attr('value',$(this).attr('value'));
25 $(this).parent().siblings('span.selected').html($(this).html());
26 });
27 });
28};
400function noSelect($elem, options) {
401 var none = 'none';
402 bindMany($elem, options, {
403 'selectstart dragstart mousedown': returnFalse
404 });
405
406 $elem.css({
407 MozUserSelect: none,
408 msUserSelect: none,
409 webkitUserSelect: none,
410 userSelect: none
411 });
412}
16function toggleSelect(elem)
17{
18 var boolElem = elem + "_bool"
19 var boolElemHidden = boolElem + "_hidden"
20 var diffElem = elem + "_diff"
21 var isChecked = document.getElementById(boolElem).checked;
22 document.getElementById(diffElem).disabled = !isChecked;
23 document.getElementById(boolElemHidden).checked = isChecked;
24}
83function clearSelect(klass, remove) {
84 var elems = document.querySelectorAll(klass)
85 ;[].forEach.call(elems, function(el) {
86 el.classList.remove(remove)
87 })
88}
17function enableMultiSelect(chkboxes) {
18 var lastChecked = null;
19 chkboxes.click(function (e) {
20 if (!lastChecked) {
21 lastChecked = this;
22 return;
23 }
24 if (e.shiftKey) {
25 var start = chkboxes.index(this);
26 var end = chkboxes.index(lastChecked);
27 chkboxes.slice(Math.min(start, end), Math.max(start, end) + 1).prop('checked', lastChecked.checked);
28 }
29 lastChecked = this;
30 });
31}

Related snippets