For modern browsers:
var checkedValue = document.querySelector('.messageCheckbox:checked').value;
By using jQuery
:
var checkedValue = $('.messageCheckbox:checked').val();
Pure javascript without jQuery
:
var checkedValue = null; var inputElements = document.getElementsByClassName('messageCheckbox'); for(var i=0; inputElements[i]; ++i){ if(inputElements[i].checked){ checkedValue = inputElements[i].value; break; } }
Related Posts:
- How do I check whether a checkbox is checked in jQuery?
- How do I check whether a checkbox is checked in jQuery?
- Check if checkbox is checked with jQuery
- Check if checkbox is checked with jQuery
- Setting “checked” for a checkbox with jQuery
- How to check all checkboxes using jQuery?
- Javascript checkbox onChange
- How do I check whether a checkbox is checked in jQuery?
- jQuery checkbox change and click event
- How to implement “select all” check box in HTML?
- addEventListener vs onclick
- How do I check if an array includes a value in JavaScript?
- JavaScript document.getElementById().value logs empty value
- What is console.log?
- Cannot read property ‘push’ of undefined when combining arrays
- window.onload vs document.onload
- Fetch: POST JSON data
- JavaScript hide/show element
- Copy array by value
- Compare two dates with JavaScript
- How do I empty an array in JavaScript?
- What’s the difference between event.stopPropagation and event.preventDefault?
- ReferenceError: fetch is not defined
- In reactJS, how to copy text to clipboard?
- SyntaxError: Adjacent JSX elements must be wrapped in an enclosing tag
- Uncaught SyntaxError: Invalid or unexpected token
- JavaScript TypeError: Cannot read property ‘style’ of null
- What is “assert” in JavaScript?
- How does the data-toggle attribute work? (What’s its API?)
- How to import image (.svg, .png ) in a React Component
- How do I embed PHP code in JavaScript?
- Make javascript alert Yes/No Instead of Ok/Cancel
- How to create a dialog with “yes” and “no” options
- Adding images to a Bootstrap Carousel with AJAX
- XMLHttpRequest cannot load XXX No ‘Access-Control-Allow-Origin’ header
- Uncaught TypeError: Cannot read property ‘props’ of null
- How to validate date with format “mm/dd/yyyy” in JavaScript?
- How to handle the `onKeyPress` event in ReactJS?
- ES6: Create Strings using Template Literals – Freecodecamp
- Youtube api – stop video
- Uncaught TypeError: Cannot read property ‘msie’ of undefined – jQuery tools
- Angular JS Uncaught Error: [$injector:modulerr]
- Uncaught TypeError: Cannot read property ‘name’ of undefined
- How to calculate date difference in JavaScript?
- React’s setState method with prevState argument
- How to measure time taken by a function to execute
- var.replace is not a function
- Uncaught TypeError: Cannot read property ‘call’ of undefined at __webpack_require__
- Can’t perform a React state update on an unmounted component
- How to simulate a click with JavaScript?
- This.props.dispatch not a function – React-Redux
- this vs $(this)
- How to open a URL in a new Tab using JavaScript or jQuery?
- “google is not defined” when using Google Maps V3 in Firefox remotely
- how to call a onclick function in tag?
- How to sort an array of integers correctly
- Failed to execute ‘postMessage’ on ‘DOMWindow’: https://www.youtube.com !== http://localhost:9000
- How can I check whether a radio button is selected with JavaScript?
- JavaScript button onclick not working
- stopPropagation vs. stopImmediatePropagation
- typescript – cloning object
- Ajax success function
- What is the equivalent of Java’s System.out.println() in Javascript?
- How can I exit from a javascript function? [duplicate]
- Object doesn’t support property or method ‘addEventListener’
- How to fix javascript .toFixed is not a Function error
- Register and enqueue conditional (browser-specific) javascript files?
- Implementing Isomorphic JavaScript (React JS) in WordPress?
- Any advantage of using wp_scripts and is_IE when enqueuing scripts
- How to replace regular jquery calls with CDN calls from Google?
- TinyMCE in a div / textarea on frontend?
- Why is this gutenberg custom format button only available from the toolbar as a dropdown?
- WordPress problem with htmlentities
- VB.net and WordPress
- Gutenberg passing block attributes to component in ES6/ESNext
- How to add a custom.js file for a child-theme in a swift way?
- WP REST API Post Status Using JavaScript
- var is undefined in a Gutenberg block
- Custom wp.editor.initialize settings ignored
- Why my javascript code not working for the dashboard of wordpress admin?
- Script Localization doesn’t work
- Got a TypeError after update and need to adapt found solution
- How do you filter the list of states when country is selected? [closed]
- Prevent update_checkout from firing mid-typing
- How to move core js files into the footer
- Building a Featured Gallery component for Gutenberg
- Suddenly extra hex string in tags
- Retrieving data about comments and likes
- Including Styles and JS files to work ON my plugin interface
- Linking wp_enqueue can’t find the javascript file (adds “?ver=x.x.x” to the src)
- Gutenberg – useEffect manipulate DOM after block re-renders DOM
- My code will not execute in wordpress, even though I’ve been told the code is fine
- Javascript working on jsfiddle but not wordpress site?
- Drodown list return issue
- Spans in gutenberg
- Get a default customizeAction text for a section using Customizer JS API
- Put dynamic Javascript in header after doing operations
- Adding javascript blocks to a single file and adding it to the header
- custom page url slug needs illegal ?id=1 for javascript
- Use one javascript variable into another javascript file