10 examples of 'jquery dropdown selected text' in JavaScript

Every line of 'jquery dropdown selected text' 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
1function selectValue(element, text) {
2 for (var i = 0; i < element.options.length; i++) {
3 if (element.options[i].text == text) {
4 element.options[i].selected = true;
5 }
6 }
7 if ("createEvent" in document) {
8 var evt = document.createEvent("HTMLEvents");
9 evt.initEvent("change", false, true);
10 element.dispatchEvent(evt);
11 } else {
12 element.fireEvent("onchange");
13 }
14}
20function setDropdownValues($dropdown, values, selectedValue) {
21 $dropdown.empty();
22 var optionsAsString = '';
23 // add an empty string to the beginning for empty selection
24 values.unshift('');
25 $.each(values, function () {
26 optionsAsString += "";
27 });
28 $dropdown.append($(optionsAsString));
29}
1function typeText(selector, text) {
2 $(selector).val(text);
3 $(selector).trigger('input');
4}
286_setSelectedValues() {
287 this.selectedItem = this.shadowRoot.querySelector("#menu").selectedItem;
288 this.selectedItemLabel = this.shadowRoot.querySelector(
289 "#menu"
290 ).selectedItemLabel;
291 this.selectedItemIndex = this.shadowRoot.querySelector("#listbox").selected;
292}
22function selectElement(input,inputText,element) {
23 var id = escapeId(input.attr('id'));
24 jQuery("input#" + id + "_AutoComplete").val(element.attr('id'));
25 jQuery("input#" + id + "_OldValue").val( inputText);
26 jQuery("input#" + id + "_AutoComplete").trigger("change");
27}
70addOption(text, disabled = false) {
71 const newOption = document.createElement('option');
72 if (disabled) { newOption.setAttribute('disabled', true); }
73 newOption.textContent = text;
74
75 this.html.options.push(newOption);
76 this.html.dropdown.appendChild(newOption);
77}
69function setDropdownValue(event) {
70 var dt = event.target.parentNode.parentNode.previousSibling;
71 dt.value = event.target.getAttribute("value");
72 dt.firstChild.textContent = event.target.textContent;
73
74 dt.parentNode.setAttribute("dropped", "false");
75
76 var evt = document.createEvent("HTMLEvents");
77 evt.initEvent("change", true, true);
78 dt.dispatchEvent(evt);
79}
81function selectCallback(value, index) {
82 $(".demo .callback_output").prepend("<p>VALUE: " + value + ", INDEX: " + index + "</p>");
83}
141select(ev) {
142 // onSelect callback
143 if (this.props.onSelect &amp;&amp; ev.target.tagName === 'A') {
144 this.props.onSelect(ev.target.getAttribute('data-mui-value'));
145 }
146
147 // close menu
148 if (!ev.defaultPrevented) this.close();
149}
66getSelectedOption(key) {
67 return this.$refs.select2.options[this.selectedIndex()].dataset[key];
68}

Related snippets