You can write:
$(document).ready(function() { $("#select-all-teammembers").click(function() { var checkBoxes = $("input[name=recipients\\[\\]]"); checkBoxes.prop("checked", !checkBoxes.prop("checked")); }); });
Before jQuery 1.6, when we only had attr() and not prop(), we used to write:
checkBoxes.attr("checked", !checkBoxes.attr("checked"));
But prop()
has better semantics than attr()
when applied to “boolean” HTML attributes, so it is usually preferred in this situation.
Related Posts:
- Using jquery to get all checked checkboxes with a certain class name
- How can I get the ID of an element using jQuery?
- How can I get the ID of an element using jQuery?
- jQuery Selector: Id Ends With?
- Set select option ‘selected’, by value
- jQuery set checkbox checked
- Wildcards in jQuery selectors
- Set selected option of select box
- jQuery Toggle Text?
- jQuery if checkbox is checked
- jQuery how to find an element based on a data-attribute value?
- jQuery: using a variable as a selector [duplicate]
- How can I change CSS display none or block property using jQuery?
- JSON parsing error syntax error unexpected end of input
- How do I check whether a checkbox is checked in jQuery?
- How to enable CORS in flask
- Change Placeholder Text using jQuery
- jQuery: Check if div with certain class name exists
- JavaScript console.log causes error: “Synchronous XMLHttpRequest on the main thread is deprecated…”
- how to loop through JSON array in jQuery?
- jQuery – how to write ‘if not equal to’ (opposite of ==)
- jQuery: Get selected element tag name
- Get element type with jQuery
- jQuery ajax error function
- How to scroll up or down the page to an anchor using jQuery?
- Passing boolean values with wp_localize_script
- Concatenate and minify dependencies for enqueued JavaScript files
- Do I need both jquery.js and jquery-migrate.min.js?
- How to load the WordPress jquery in the section
- wordpress json custom taxonomy problem
- tinymce is not defined when not using wp_editor
- Require featured image
- How can I add a jQuery OnClick event to the Publish posts button?
- As a plugin developer, how to deal with theme developer loading jquery from google?
- Draggable item in custom gutenberg block
- Best Way to Include Scripts on a Specific Template Page
- AJAX post into pop-up div
- How to include jquery validate in a template
- chosen jquery library not loading – is not a function error
- jQuery in WordPress – Why is it not working?
- jQuery UI AutoComplete not working in wordpress?
- Updating User Profile with AJAX not working
- Auto Load New Posts
- wp_ajax() question.. not using wp_enqueue_script?
- What do I need jQuery for?
- How to include jQuery when no header and footer on the page
- Showing Author Information and Latest Post by author in lightbox when clicked on the name of the author
- Load jQuery inside Page Template
- WP Admin missing icons, numerous JavaScript errors, but only when SCRIPT_DEBUG is false
- Returning content via jQuery without footers on admin pages
- Make inline edit in wp_list_table
- Ajax, Permalinks and post_thumbnail
- Will the latest Bootstrap work properly with the default WordPress jQuery?
- jQuery is missing in wp-admin
- How to embed JS data viz in a simple WordPress website
- Rhyzz Repeatable-fields javascript in php and wordpress
- How can I integrate User generated/dynamic fields in Contact form 7?
- Using Bootstrap Switch with WordPress
- wp_enqueue_ scripts
- Yoast SEO breaking media upload
- window.onload wont execute in wordpress
- How to fix my old theme so it loads jQuery properly
- Plugin Scripts no loading on options page
- Is there some way to refactor this jQuery wrapper?
- Readonly input text appears unlocked while the page is loading
- Run JS function when JQ enqueued
- underscore template dynamically remove row Jquery
- Multiple selec2.js file loaded by several plugins
- Safe method to temporarily load second jquery library to wordpress
- How to use wp_update_post with ajax on frontend
- including jquery
- Customizing the Jquery Calendar [closed]
- Drag and Drop Metadata Menu Order
- need jquery help
- How to enable read more by default using jquery
- Show and hide element when URL contains certain section of text?
- how to allow download after newsletter subscription?
- How to insert fancybox to multiple separate galleries in a post?
- Notify user we would like them to clear their cookie. Provide a working button to clear cookies for user
- Call full image url instead of stylsheet directory url in JS for Infinite Scroll Function
- jQuery.post() calling function with parameter
- Passing variable data from external jQuery file to options.php
- Custom Javascript not working? [closed]
- What to do after a wrong RewriteRule?
- How to deregister scripts all at once
- Using jQuery DataTables and yadcf
- Jquery script not loading on site Front page
- jQuery autcomplete not working
- Javascript block in Twenty Twelve theme
- jQuery drop down not appearing for autocomplete/autosuggest
- jQuery dialog prints HTML-Tags under WordPress
- TypeError: $ is not a function Error using parallax effect in WordPress Template [duplicate]
- Loading custom file based on a dependant file that is also dependant on another file
- Auto Sorting List Alphabetically
- Change WooCommerce Checkout Manager Datepicker to Jalali
- Does anyone know how to load jquery in the footer?
- Use WordPress Built In Jquery
- Generate dynamic ID’s for each accordion button
- Impossible to update jQuery version from 3.1.0
- Enqueued jQuery not working