I have a Special Idea about an Edit function

前端 未结 1 897
小蘑菇
小蘑菇 2021-01-27 14:43

All the Functions below are under a $(document).ready(function()) !

First I have an input which you can fade in/out its looks like this:

相关标签:
1条回答
  • 2021-01-27 15:09

    at the moment it looks like this:

    $("#liste").click(function selectList (event) {
        var target = $( event.target );
        if ( target.is( "li" ) && !$("li").hasClass('selected')) {
            target.addClass('selected');
        }
        else if (target.is( "li" ) && $("li").hasClass('selected')) {
            target.removeClass('selected');
        }
    });
    
    $('.deleteSel').click(function delSelectedEntries () {
        alert("Ausgewählte Beiträge wuden gelöscht");
        var sel = $('.selected'); //stores the entrys 
        sel.remove(); // removes only the list entrys temporaly
    });
    
    $(".edit").click(function editSelectedEntries(){    
        var index = $('.selected').attr("index");
        edit(index);
    });
    

    edit Function:

    function edit (index){
    
        $( "#block" ).fadeIn(500);  
        $( "#block" ).animate({width: '54.4%', opacity: '0.8',fontSize: '1.5em'}, 750);
        $( "#block" ).animate({height: '40%', opacity: '0.8', fontSize: '3em'}, 750);
    
        $('#alter').val(list[index].alter);
        $('#vorname').val(list[index].vorname);
        $('#nachname').val(list[index].nachname);   
        $('#geschlecht').val(list[index].geschlecht);
    
        $('.send').click(function onClick(){ 
    
            var age = $('#alter').val(); 
            var preName = $('#vorname').val();
            var secName = $('#nachname').val();         
            var gender = $('#geschlecht').val();
    
            list[index] = {
                vorname: preName,
                nachname: secName,
                alter: age,
                geschlecht: gender
            };
    
            generateList();
        });
    
    0 讨论(0)
提交回复
热议问题