Checkbox value always on

Hi…when getting the value of a checkbox it is always on

document.getElementById(“micheck”).value

Any ideas

Thanks

i found the solution:

document.getElementById(“micheck”).checked

Also, at your convenience, since you have jQuery coming with all BSS’s designs, you can benefit of it in your own code:

const state = $('#micheck').prop('checked');  // true when checked

or

const state = $('#micheck').attr('checked');  // "checked' when checked

or

const state = $("#micheck").is(':checked');  // true when checked

jQuery isn’t used in all bss designs. Only bootstrap 4 and lower, bootstrap 5 did away with jQuery.

1 Like

Didn’t use Bootstrap 5 until now. So, good to know… Thanks!

1 Like

There are a handful of sites that I have on BS5, but still using some jQuery so it still works, you just have to turn it on in your project settings if you want/need it.

2 Likes

Thanks too, @jo-r! Sure I’ll use Bootstrap 5 through BSS a day or another, with or without added jQuery… Even if, to be frank, before BSS (and some others I tried and didn’t convince me like BSS does), I was used to build websites and various front-ends without any framework. BSS changed my point of view.

Glad it brought you hear elroot, you’ve been very helpful on the forums and that’s always needed. I’m somewhere in between having a clue and being clueless so yeah there’s that lol.

I use it periodically for older sites that the functions they used on the old site still does well with the BS5 site so if it ain’t broke, don’t fix it is my motto lol.

I came from hand coding in Dreamweaver (their visual setup sucks lol) and was using Bootstrap already so coming to this was a Godsend so to speak. Haven’t looked back, not even once. Came in when it was still pretty raw and didn’t have 3/4 of the features it has now and I stuck with it because they heard us when we asked for things so that’s always a good thing. I think it’s a keeper :slight_smile:

1 Like

I prefer not to use jquery in my new projects.

Thanks for all the replies.

@jo-r Dreamweaver, yeah… At time of its first release (~97), I was with HoTMetaL :wink: But, well… It was not the comfort of BSS, Bootstrap, and even CSS!

@cesarechazu Mainly, in the past, jQuery was welcome for cross-browser compatibility… When vanilla Javascript was not so widely supported; and we had to reinvent the wheel every morning. But now, it’s just a matter of preference (not talking about embedded systems) :slight_smile:

should I stop using jquery in my new projects?

I think that jquery still has a long way to go, only that there are tools that have advanced a lot, a couple of years ago I started testing with Vue and it is my favorite.
It’s just a point of view, just that.

1 Like