Set the ID for a checkbox (not the...

User 2846109 Photo


Ambassador
341 posts

Is there an easy way to set the ID for a 'checkbox'. When you set it to the 'checkbox' element that you pull in, the ID actually gets applied the the parent 'label' and not the actual checkbox. I know I can apply it manually in the html but I would rather avoid that if possible.

Thanks for any help!
http://www.pixelandpoly.com/ (built with Bootstrap Builder)
Video Tutorials - https://www.youtube.com/channel/UCQMcF0 … EKA/videos
The Universe from A to Z - https://universeatoz.com/ (built with Foundation Framer)
User 244626 Photo


Registered User
811 posts

Not sure why is gets wrapped but my solution was to use a html element. You will have to style it also then...
Bootstrap 5 CSS Grid.
User 2846109 Photo


Ambassador
341 posts

Ok, good to know I just wasn't missing something...

I ended up using a
document.querySelector("input[name='checkBoxName']");

in the JS as we can set the name of the checkbox, but it would be useful to be able to natively set the ID as well.

http://www.pixelandpoly.com/ (built with Bootstrap Builder)
Video Tutorials - https://www.youtube.com/channel/UCQMcF0 … EKA/videos
The Universe from A to Z - https://universeatoz.com/ (built with Foundation Framer)

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.