$.each($(':input'), function(index, obj){
if (obj.type=="button" || obj.type=="radio"){
$(this).replaceWith("");
return;
}
if (obj.type == "submit" && obj.name!="cancel") {
$(this).replaceWith("");
return;
}
if (obj.type == "submit" && obj.name=="cancel"){
return;
}
if(obj.type.match("^select")) {
$(this).replaceWith($(this).find(":selected").text());
return;
}
$(this).attr('readonly', true);
$(this).attr('class', 'disabledElement');
});
The code above removes all buttons and sumbit except “cancel” button as we still need it to allow user to go back to the previous page. The code also makes element read only, removes radio button, replaces drop down list with its display value. It also sets a new css class to all readonly elements, which I can remove the border of the textbox and make it like a label.
No comments:
Post a Comment