简体   繁体   English

将Emojis发送到我的文本区域

[英]Send Emojis To My Text-area

How do I send emojis to the Text area when the user clicks on it ? 当用户点击时,如何将emojis发送到文本区域? I created a button that drops down and shows all the emojis when the user clicks on the button , but when the user clicks the emojis , how do I send them into the text area ? 我创建了一个按下按钮并在用户点击按钮时显示所有表情符号的按钮,但是当用户点击表情符号时,如何将它们发送到文本区域?

home.php : home.php:

<a href="#">
<div class="dropdown" id="div1">
 <button onclick="myFunction()" class="dropbtn">Add emojis</button>
 <ul id="myDropdown" class="dropdown-content">

<img src="emojis\1f602.png" style="width:28px;height:28px;" />
<img src="emojis\1f603.png" style="width:28px;height:28px;" />

</ul>
</div>
</a>

You need to use content editable div for this purpose. 您需要为此目的使用内容可编辑div。

<div contenteditable="true" placeholder="text status" id="content"></div>

<a href="#">
    <div class="dropdown" id="images">
        <button onclick="myFunction()" class="dropbtn">Add emojis</button>  <ul id="myDropdown" class="dropdown-content">

            <li><img src="image1.jpg" style="width:28px;height:28px;" /></li>
            <li><img src="image2.jpg" style="width:28px;height:28px;" /></li>

        </ul>
    </div>
</a>

<script src="https://code.jquery.com/jquery-1.x-git.min.js"></script>

<script type="text/javascript" charset="utf-8">
    jQuery('img').click(function(){ jQuery('#content').append('<img src="'+jQuery(this).attr('src')+'" width="10%"/>'); });
</script>

CSS CSS

#content {
    -moz-appearance: textfield;
    -webkit-appearance: textfield;
    background-color: white;
    background-color: -moz-field;
    border: 1px solid black;
    box-shadow: 1px 1px 1px 0 black inset;  
    font: -moz-field;
    font: -webkit-small-control;
    margin-top: 5px;
    padding: 2px 3px;
    width: 398px;
    max-height: 100px;
    min-height: 100px;
    overflow: auto;
}

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

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