Php 如何从diva中获取contenteditable的值

Php 如何从diva中获取contenteditable的值,php,jquery,Php,Jquery,在输入内容可编辑后,如何获取其值 在我单击div并编辑文本并将其发送到php之后,是否有方法获取它的值 顺便说一句,我使用jquery和php来实现这一点。 这是我的密码: <div class="profilestatus"> <a contenteditable>type text here</a></div> 在此处键入文本 var短语='在此处键入文本'; var myRegexp=您的匹配模式; var match=myRegexp.e

在输入内容可编辑后,如何获取其值

在我单击div并编辑文本并将其发送到php之后,是否有方法获取它的值

顺便说一句,我使用jquery和php来实现这一点。 这是我的密码:

<div class="profilestatus"> <a contenteditable>type text here</a></div>
在此处键入文本
var短语='在此处键入文本';
var myRegexp=您的匹配模式;
var match=myRegexp.exec(短语);
警报(匹配[1]);
改用
。您可以使用CSS将其样式设置为类似HTML的样式:

<input value="editable"></input>
也许:

$('#yourForm').submit(function() {
    $('#hiddenInput').attr(
        'value',
        $('.profilestatus').first().children(0).html()
    );
});
?


您还可以使用CSS设置
样式。这将避免您有隐藏的输入。

我一直在尝试让内容自动突出显示,但无论是JS还是jQuery都无法做到:(

无论如何,这就是我所拥有的:

工作示例:


功能表单提交(内容)
{
document.eForm.link.value=内容;
document.eForm.submit();
}

您是否尝试过将其放入表单中?没有,但我现在就尝试。输入必须始终位于表单中。即使您使用AJAX并忽略表单的操作,将您的输入放入表单中仍然更为清晰。如果您耐心等待,我正在做一些事情:)我正在输入,但是当没有区域时,文本总是分散的。如何使文本在文本字段中始终可见。
$("input").focusout(function(){
    alert($(this).val());
});
$('#yourForm').submit(function() {
    $('#hiddenInput').attr(
        'value',
        $('.profilestatus').first().children(0).html()
    );
});
    <script>
        function formSubmit(content)
        {
            document.eForm.link.value = content;
            document.eForm.submit();
        }
    </script>
    <?php
        $link = isset($_POST['link']) ? $_POST['link'] : NULL;
        ($link !== NULL) ?
        ((stripos($link, 'http://') === FALSE) ?
        header('Location: http://'.strip_tags($link)) :
        header('Location: '.strip_tags($link))) : true;
    ?>
    <form name="eForm" method="Post" action="<?php echo $_SERVER['PHP_SELF'] ?>">
        <input id="try" type="hidden" name="link" />
        <div id="eDiv" class="profilestatus" contenteditable>
            <a id="eLink" onclick="formSubmit(document.getElementById('eLink').innerHTML)">highlight, type, click!</a>
        </div>
    </form>