简体   繁体   中英

remove disabled property from a html object in jquery

I am adding html on my page on click of a button.So when i adding the html i want to remove all the disabled property from the html variable so that the new html don't have any disabled inputs :

Code:

var current_td = $(thisobj).closest('tr').html();
    var next_td = $(thisobj).closest('tr').siblings('tr.add').html();
    var added1 = '<tr class="class2">'+current_td+'</tr>';
    var added2 = '<tr class="class1">'+next_td+'</tr>';
    var main_html = added1 + added2;
    main_html = main_html.replace("Add[+]" ,"Remove [-]");
    $('#create_table').append("<tbody id=TBody"+Count+">"+main_html+"</tbody>");
    masterCodeCount++;
    return "TBody"+(Count-1);

From main_html variable i want to remove the disabled property of the inputs types.Because from where i am getting the html the inputs type are disabled

You can do

var current_td = $(thisobj).closest('tr').html();
var next_td = $(thisobj).closest('tr').siblings('tr.add').html();
var added1 = '<tr class="class2">' + current_td + '</tr>';
var added2 = '<tr class="class1">' + next_td + '</tr>';
var main_html = added1 + added2;
main_html = main_html.replace("Add[+]", "Remove [-]");
var $main = $(main_html);
//remove the disabled attribute
$main.find(':disabled').removeAttr('disabled');
$("<tbody id=TBody" + Count + "></tbody>").append($main).appendTo('#create_table');
masterCodeCount++;
return "TBody" + (Count - 1);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM