logo
down
shadow

Get value from select type by jquery


Get value from select type by jquery

By : jopes
Date : November 19 2020, 03:01 PM
it should still fix some issue If your html is like this (and note, I've added a class 'test-class' to make selection easier):
code :
<div class="sf-field-post-meta-typeofmeal">
    <select class="sf-input-select">
        <option value="breakfast">Breakfast</option>
        <option value="candy">Candy </option>
        <option value="coffeeshop">Coffeeshop</option>
    </select>
</div>

<div class="sf-field-post-meta-breakfast test-class" hidden>Breakfast description</div>
<div class="sf-field-post-meta-candy test-class" hidden>Candy description</div>
<div class="sf-field-post-meta-coffeeshop test-class" hidden>Coffeeshop description</div>
$(function () {

    $('.sf-field-post-meta-typeofmeal .sf-input-select').change(function () {
        // Hide all the divs using the 'test-class' selector
        $.each($('.test-class'), function () {
            $(this).hide();
        });
        // Check the value selected and show the associated div
        switch ($(this).val()) {
            case 'breakfast':
                $('.sf-field-post-meta-breakfast').show();
                break;
            case 'candy':
                $('.sf-field-post-meta-candy').show();
                break;
            case 'coffeeshop':
                $('.sf-field-post-meta-coffeeshop').show();
                break;
        }
    });
    // Trigger 'change' when the html document has loaded to set the div visibility
    $('.sf-field-post-meta-typeofmeal .sf-input-select').trigger('change');

});


Share : facebook icon twitter icon
HTML select element type is 'select-one' when jQuery is included. Is it a cross browser value?

HTML select element type is 'select-one' when jQuery is included. Is it a cross browser value?


By : user2616409
Date : March 29 2020, 07:55 AM
wish helps you The type property is actually a DOM property native to form input elements, and doesn't have anything to do with jQuery - you can quickly corroborate this by running this on any website:
code :
console.log(document.createElement('select').type);
jquery select next tag, but not of the same type

jquery select next tag, but not of the same type


By : Alan
Date : March 29 2020, 07:55 AM
it should still fix some issue Just use this, you can specify the selector while using next so it will look for that in the siblings.
code :
$('h5').next("div");
how to get type of select using jQuery

how to get type of select using jQuery


By : user3750941
Date : March 29 2020, 07:55 AM
around this issue How I can get type of a select element using jquery?I mean I get that a specific element is DropDownList or ListBox? , here you are
code :
if ($("#select_id").attr("size") > 0) {
    // listbox
}
else {
    // dropdown
}
jQuery select via data-type

jQuery select via data-type


By : user2235536
Date : March 29 2020, 07:55 AM
Hope that helps Trying to set a value on an input box but only if it's inside a td where data-type=2 , Use the attribute selector:
code :
$('td[data-type=' + key + ']').children(".amount").val(value );
How to select a select type = multiple - jQuery

How to select a select type = multiple - jQuery


By : CRizzo
Date : March 29 2020, 07:55 AM
wish of those help Simple using the Has Attribute Selector...
Related Posts Related Posts :
  • Slider with touch function
  • ReactJS Component Architecture Problems / Nested Components or Single Component Manager
  • Javascript: Caching within Closure doesn't work
  • HTM5 Canvas Drawing App: How Do I Select The Color?
  • Assigning Events using HTML DOM
  • html5 getUserMedia() portrait mode
  • How to avoid 'headers already sent' within Promise chain?
  • Get a result from a react native app integrated into an existing android app
  • Why does the value of input field return undefined
  • How to get return object in jquery uploadFile method
  • Javascript string with arguments to single quotes
  • Understanding JS functions syntax (applies to other languages as well, I'm sure)
  • AngularJS Single Page App: Reference Error, ____ is not defined
  • whatwg-fetch new typescript 2.5.3
  • React.js - Array.unshift() not updating array on front-end
  • JavaScript localeCompare don't sort well [ "aaa-1.0", "aaa-1.1", "aaa-1.01", "aaa-11&
  • Mongoose handle validation error in a promise call and Express middleware
  • Building tree array of objects from flat array of objects
  • How to add a progress bar to file upload using javascript and ajax call?
  • JavaScript: is it permitted to override a standard built-in object?
  • Change the current page of an AJAX datatables
  • Array element is undefined even after pushing elements into it
  • onmousemove event not working
  • Chrome-Extension/JavaScript How to make all links on page have no effect?
  • Websocket issue Internet Explorer
  • sessionStorage value becomes null in other tab in AngularJS
  • Split URL from position x to the end in Javascript
  • How to set value of input field with NgIf in Angular 4
  • invalidStateError for second time screenshare on Chrome
  • How do you pass a value to the variable in a xhr.setRequestHeader?
  • I cant start nodemon on my windows 10
  • Nested if else jumps out from the main if else in javascript
  • Iterate through all collections and remove them
  • ES6 - Value of a variable in template string does not increment
  • how to get content of html table cell using javascript javascript depending on checkbox
  • Node.js Working with Multiple Tier SQL
  • Can't allow Cross-Origin Request in local Nodejs server
  • Datatables orderable=false directly on table
  • Dynamically load js content with iron router in meteor using array in return statement
  • Limit checkbox to 2, but moving the select instead of blocking it
  • Why itsn't displaying marker on map?
  • jQuery target next of the same class in the whole DOM
  • encoding must be a valid encoding error in process encoding
  • How to do a date range to view data from selected date highcharts
  • How do I refactor this composed function with Ramda.js?
  • jQuery to serialize selected option's value, not label
  • Convert object to Chartis.js structure
  • Dynamic import with not bundled file
  • Click handler not firing for elements rendered in Ajax Callback - only in Safari
  • Math.max.apply gives an error CreateListFromArrayLike called on non-object
  • get the parent nodes to a given node in d3 dendogram
  • is-dropdown-submenu-parent makes links unclickable on Opera and Chrome
  • JS: Sum column values and updating result on change
  • Query against nested object keys
  • Fullcalendar getting its parent colspan
  • How to retrieve a dynamic number of elements by id
  • How to access redux variables and functions from deep components
  • Efficiently access Array.prorotype.filter single-item returns
  • PHP var into Javascript
  • How to parse json with javascript/jquery if content matches string
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org