0

I used link buttons in my site. At Starting the "Delete" button should disable. After click "Add" button it will be enable. But I cant achieve. I don't know what mistake i made. Any one Please correct ?

enter code here

if ($('.' + inputContainerCss).length < 3) {
    //    if ($('.' + inputContainerCss).length < 2) {
    $('#' + btnDelId).attr('disabled', 'disabled');
}

  $('#' + btnAddId).click(function () {
    var num = $('.' + inputContainerCss).length; // how many "duplicatable" input fields we currently have
    var newNum = new Number(num + 1);   // the numeric ID of the new input field being added

    // create the new element via clone(), and manipulate it's ID using newNum value
    var newElem = $('#' + inputContainerIdPrefix + num).clone().attr('id', inputContainerIdPrefix + newNum);

    // manipulate the name/id values of the input inside the new element
    //newElem.children(':first').attr('id', firstChildInputIdPrefix + newNum).attr('name', firstChildInputIdPrefix + newNum);


    newElem.children().each(function () {
        var idPrefix = $(this).attr('id').substring(0, $(this).attr('id').length - 1);
        var namePrefix = $(this).attr('name').substring(0, $(this).attr('name').length - 1);
        $(this).attr('id', idPrefix + newNum).attr('name', namePrefix + newNum);
    })

    // insert the new element after the last "duplicatable" input field
    $('#' + inputContainerIdPrefix + num).after(newElem);

    // enable the "remove" button
    $('#' + btnDelId).attr('disabled', '');
3
  • Could you give us more details about your usecase? What are you doing and what you want to get? Commented Sep 11, 2012 at 10:56
  • What exactly doesn't work? It the button initially disabled? Can't you enable it? Or doesn't it work to make him disabled again after removing elements? Can you create a jsfiddle? Commented Feb 12, 2013 at 9:57
  • The button is always disable only. I want to enable it. Commented Feb 12, 2013 at 10:22

1 Answer 1

1

This is not your coding Issue. You have to add some jquery files for this like,

Just clik the link and download it.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.