Change Label to Textbox on edit hyperlink click

前端 未结 5 1068
花落未央
花落未央 2020-12-05 09:01

I am new to ruby on rails and twitter bootstrap. Accept my apologize if my question sound dumb. I am using twitter bootstrap for my site design. I have been trying to use b

5条回答
  •  情歌与酒
    2020-12-05 09:26

    Use a hidden input

    When user click on "Edit", grab the text from text-info (eg Saghir), hide the label, show the input and set the inputs placeholder-attribute.

    function edit(element) {
        var parent=$(element).parent().parent();
        var placeholder=$(parent).find('.text-info').text();
        //hide label
        $(parent).find('label').hide();
        //show input, set placeholder
        var input=$(parent).find('input[type="text"]');
        $(input).show();
        $(input).attr('placeholder', placeholder);
    }
    

    working fiddle : http://jsfiddle.net/TKW74/

提交回复
热议问题