0

I'm trying check a radio button with jquery but it stays unchecked:

$("#show_slideshow_link_no").attr('checked', 'checked');
$("#show_slideshow_link_no").prop('checked', true);
console.log($("#show_slideshow_link_no").is(':checked')); // prints false

even when I execute the code from console it prints false

However, if I do $("#show_slideshow_link_no").remove(); the radio button disappears.

What am I missing?

Ian Hogers
  • 45
  • 1
  • 9
  • Show the html code also. Could be that it is not really a checkbox and only looks like one – Endless Jan 19 '18 at 14:22
  • 1
    https://stackoverflow.com/a/426276/7955781 have a look at this answer maybe – C. Henke Jan 19 '18 at 14:23
  • use `.prop()` also make sure that the there is no same ID in the context since you are using ID it should be unique. We need to see the HTML mark up to be able to tell what is wrong. Also check console for error – guradio Jan 19 '18 at 14:24
  • Without seeing the HTML part I could guess that your radio button has a different ID than your jQuery selection. – OlafW Jan 19 '18 at 14:59
  • @C.Henke thanks, i'll try some of the things they're suggesting. @guradio I've check to see if there's no same ID in the context, but there isn't. and i'm always monitoring the console and using `console.log();` to check values and find proper selectors. @OlafW the problem is, is that button i'm trying to modify is part of an iframe that is being loaded into the dom after a button is pressed, it's part if a image gallery plugin for wordpress. – Ian Hogers Jan 21 '18 at 20:14

0 Answers0