简体   繁体   English

如何将href回应到可编辑的div

[英]How to echo href to editable div

I am attempting to echo a link into an editable div. 我正在尝试将链接回显到可编辑的div中。 This is handled by JQuery and then passed to an html file. 这由JQuery处理,然后传递到html文件。 echo in php script 在PHP脚本中回显

echo "<a href='Olliff_index.html'>Return to Main Menu</a>";

Received by 收到者

var formData = $('#billingForm,#videoForm').serializeArray();
        $.post('Olliff_receipt.php', formData, function(data) {
            $('div#Wrapper').empty().append(data);
        });

div#Wrapper references div#Wrapper参考

<div id="Wrapper" contenteditable="true">
        <div id="form">
        <h3>Bob's Order Form</h3>
        <p>Please Select a Department</p>
        <br />
        <form id="videoForm">
            <div id="header" contenteditable="true" align="center"></div>
            <div style="height:200px;overflow:auto;" id="department" contenteditable="true"></div>
            <br />
            <input type="button" id="submit" value="Submit"/> <input type="button" id="reset" value="Reset"/>
            <div id="msg" contenteditable="true"></div>
        </form>
        </div>
    </div>

The result is the text "Return to Main Menu" and it appears to be a link (underlined blue font) but is not clickable. 结果是文本“返回主菜单”,它似乎是一个链接(带下划线的蓝色字体),但不可单击。 Some extra info I'm not sure is related is this is all taking place within Olliff_index.html so the href is linking to the file it is in but that shouldn't matter right? 我不确定一些额外的信息是否相关,因为这都是在Olliff_index.html中进行的,因此href链接到了它所在的文件,但这没关系吧?

In your js, try to add this: 在您的js中,尝试添加以下内容:

var formData = $('#billingForm,#videoForm').serializeArray();
    $.post('Olliff_receipt.php', formData, function(data) {
        $('div#Wrapper').empty().append(data);
        $('div#Wrapper').removeAttr('contenteditable'); //new line
    });

With this change, your href will be clickable 进行此更改后,您的href将可以点击

It's because of the attribute: 这是由于属性:

contenteditable="true"

in the 在里面

<div id="Wrapper" contenteditable="true">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM