I need to add this code to my functions.php file for wordpress.
jQuery('#billing_piegadatajs_field').find('input[name="billing_piegadatajs"]').each(function() {
jQuery(this).prop('checked', false);
But no matter how i try this, it doesnt work. I have close to NONE experience with coding, so please tell me exactly what to do from A-Z, don't assume that i have any idea what your talking about if you just post a code out of context like i did above. I dont know what to do with it, that is the problem.
I tried putting it in functions.php like this, but it just grey's out the middle part.
function uncheck_radio() {
$script2 = '<script type="text/javascript">
jQuery(document).ready(function(){
jQuery('#billing_piegadatajs_field').find('input[name="billing_piegadatajs"]').each(function() {
jQuery(this).prop('checked', false);
});
</script>';
echo $script2;
}
add_action( 'wp_footer', 'uncheck_radio' );
I tried like 10 variations of how to add this, but it just doesnt work. Please help!
EDITED: It seems the code itself is not working to remove the checked radio when loading page.
i found that this script is said to be working. Could you help me implement it?
(function ($) {
$.fn.uncheckableRadio = function () {
return this.each(function () {
var radio = this;
$('label[for="' + radio.id + '"]').add(radio).mousedown(function () {
$(radio).data('wasChecked', radio.checked);
});
$('label[for="' + radio.id + '"]').add(radio).click(function () {
if ($(radio).data('wasChecked'))
radio.checked = false;
});
});
};
})(jQuery);
my input ype radio name="billing_piegadatajs" and the default checked value="stacijas" Could you help me implement this?
Use double quotes everywhere within the single quoted area. The first single quote before #billing_ is closing the quoted area.
Also, escape the quotes around the input name (escape means (in short!) 'don't treat these as quote marks' - you typically escape a character by preceding it with some sort of control character, in this case a backslash).