Try to search your question here, if you can't find : Ask Any Question Now ?

Remove parent div on button press

HomeCategory: stackoverflowRemove parent div on button press
Avatarpushpa asked 11 months ago

trying to create a dynamic button system to add/remove inputs on clicks. I have the addButton working but not the deleteButton. What am I missing?

$(document).ready(function() {
    var maxFields = 20;
    var addButton = $('#plusOne');
    var deleteButton = $('#minusOne');
    var wrapper = $('#userNumbers');
    var fieldInput = '<div><input type="text" name="persons" id="persons"/></div>';
    var x = 1;

    $(addButton).click(function () {
        if (x < maxFields) {
            x++;
            $(wrapper).append(fieldInput);
        }
    });

    $(deleteButton).click(function(e) {
        e.preventDefault();
        $(this).parent('div').remove();
        x--;
    });

});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button type="button" id="plusOne">+</button>
    <button type="button" id="minusOne">-</button>

    <div id="userNumbers">
       <p>
        <input type="text" id="person" name="person">
        </p>
    </div>
2 Answers
Best Answer
AvatarFernando answered 11 months ago
AvatarTyroneArous answered 3 months ago

後宮情色線上影音網 – 中文有碼 中文無碼 番號搜索

http://50-video.com/

Your Answer

2 + 9 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com