is there a way to disable all fields (textarea/textfield/option/input/checkbox/submit etc) in a form by telling only the parent div name in jquery/javascript?
Try using the :input selector, along with a parent selector:
$("#parent-selector :input").attr("disabled", true);
Only text type
$(".form-edit-account :input[type=text]").attr("disabled", "disabled");
Only Password type
$(".form-edit-account :input[type=password]").attr("disabled", "disabled");
Only Email Type
$(".form-edit-account :input[type=email]").attr("disabled", "disabled");
$(document).ready(function () {
$('#chkDisableEnableElements').change(function () {
if ($('#chkDisableEnableElements').is(':checked')) {
enableElements($('#divDifferentElements').children());
}
else {
disableElements($('#divDifferentElements').children());
}
});
});
function disableElements(el) {
for (var i = 0; i < el.length; i++) {
el[i].disabled = true;
disableElements(el[i].children);
}
}
function enableElements(el) {
for (var i = 0; i < el.length; i++) {
el[i].disabled = false;
enableElements(el[i].children);
}
}
$('#mydiv').find('input, textarea, button, select').attr('disabled','disabled');
Simply this line of code will disable all input elements
$('#yourdiv *').prop('disabled', true);
Use the CSS Class to prevent from Editing the Div Elements
CSS:
.divoverlay
{
position:absolute;
width:100%;
height:100%;
background-color:transparent;
z-index:1;
top:0;
}
JS:
$('#divName').append('<div class=divoverlay></div>');
Or add the class name in HTML Tag. It will prevent from editing the Div Elements.