javascript create checkbox with label
const inputActiveElement = document.createElement('input');
inputActiveElement.classList.add('mr-2');
inputActiveElement.id = `active_image`;
inputActiveElement.type = 'checkbox';
inputActiveElement.value = '123';
inputActiveElement.name = 'active_image[]';
inputActiveElement.setAttribute('checked','true');
const labelActiveElement = document.createElement('label');
labelActiveElement.setAttribute('for',`active_image`);
labelActiveElement.innerText = 'Active';
const divInnerElement = document.createElement('div');
divInnerElement.classList.add('form-inline');
divInnerElement.classList.add('mt-2');
divInnerElement.append(inputActiveElement, labelActiveElement);
Also in JavaScript:
- Angular empty object
- how to get file extension in javascript last index
- get multiple checkbox value in javascript
- javascript assignment operator if undefined
- send message to specific channel discord.js
- debugger js
- refresh data after some time angular
- js get file name from path
- badlion client
- angular file upload app with django
- node js mongoose text index
- next js create store
- javascript get srollwidth
- render props
- cannot find module @babel/compat-data/data/corejs3-shipped-proposals
- call laravel route js
- funciones invocan a funciones javascript
- how to create a component in react native
- jquery disable class attribute
- parsley validation checkbox alignment
- displaying the date react
- route react
- chart.js label word wrap
- split a message js