Placeholder in contenteditable - focus event issue

后端 未结 11 2110
无人共我
无人共我 2020-12-07 10:05

I have been trying to ask this before, without any luck of explaining/proving a working example where the bug happens. So here is another try:

I’m trying to replicat

11条回答
  •  难免孤独
    2020-12-07 10:27

    var curText = 'Edit me';
    $('div').focusin(function() {
        if ($(this).text().toLowerCase() == curText.toLowerCase() || !$(this).text().length) {
            $(this).empty();
        }
    }).focusout(function() {
        if ($(this).text().toLowerCase() == curText.toLowerCase() || !$(this).text().length) {
            $(this).html('' + curText + '');
        }
    });
    

提交回复
热议问题