How can I add an emoji picker button to a textbox?

Is there a way to incorporate an emoji picker button within a text box for selecting emojis without using jQuery, only utilizing CSS and core JavaScript? I am looking to implement an emoji picker similar to WhatsApp that allows users to insert emojis directly into a text area.view image description

Answer №1

If you're looking to create a WhatsApp-like emoji picker, it would be helpful to have an image or more details on what exactly you're aiming for.

However, emojis are considered regular characters and can be added to text areas using buttons if the user's keyboard doesn't support emoji typing. Here's a quick example:

const addEmoji = char => document.querySelector('textarea').value += char;
<div>
  <button onclick="addEmoji('💸')">💸</button>
  <button onclick="addEmoji('🎉')">🎉</button>
  <button onclick="addEmoji('🎁')">🎁</button>
  <button onclick="addEmoji('☎️')">☎️</button>
</div>

<textarea rows="5" cols="30">
Type text here, or click on an emoji above to add it
</textarea>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Closing Note in Drupal

Is there a way to adjust the footer message in Drupal without logging into the dashboard? I've checked all the files in cPanel, but I can't seem to locate the actual HTML for the website. I am only able to customize the body content, not the fo ...

Scrolling the y-axis with a fixed height limit to prevent overflow

My current dilemma is a seemingly simple one: <div class="container"> <div class="a"></div> <div class="b"></div> <div class="c"></div> </div>​ Within the container, there are 3 divs: A and B ...

Click event not triggering to update image

I'm currently working on a Codepen project where I want to use JavaScript to change the image of an element with the id "chrome". However, my code doesn't seem to be working as expected. Can someone help me troubleshoot and fix this issue? Your a ...

Adjust the initial slider according to the values displayed in the following four sliders

Having an issue updating the slider value in the first one based on selected values from four other sliders. The selected value should not exceed 50, which is the maximum value in the first slider. Link to Working Fiddle : Below is the HTML code : & ...

Tips for utilizing ng class within a loop

Having some trouble with my template that loops through a JSON file using json server. The issue I'm facing is related to correctly applying ng class when clicking on icons. Currently, when I click on an icon, it adds a SCSS class but applies it to al ...

Adjust the style of cursor - User Interface Expansion Panel Material Design

Using the MiU component "Expansion panel", I encountered an issue. By default, when the user hovers over the panel, the cursor is set to pointer. I attempted to change it to a default cursor, but my modification did not work. The code for my component is ...

How to Align a Footer to the Bottom of the Page using Bootstrap 5

My issue arises when using a dark background footer, as some pages lack enough content to fill the entire browser's viewport. Consequently, an unsightly white band appears below it. How can I ensure the footer reaches the bottom of the viewport on pa ...

Strategies for styling the contents within <details> while excluding <summary> in CSS

I'm attempting to apply a 10px padding to the Story box using CSS, without introducing any additional HTML elements into the website code. Is there a way to include the padding in the Story box without incorporating a new HTML element? To clarify: H ...

Uploaded images from mobile devices appear to be rotated when viewed on desktop browsers like Chrome and Firefox

I'm facing a strange issue where an image uploaded from a mobile device to my website appears rotated on Chrome and Firefox when viewed on a desktop. However, it displays correctly on mobile browsers like Chrome Mobile and Safari Mobile. It seems tha ...

Tips on aligning a div to the right of a headline

My goal is to have an orange circle image placed to the right of my headline <h2>. However, I am facing an issue where the circle jumps above the headline when I shrink the screen. How can I ensure that it stays on the right side no matter the screen ...

Adjusting the CSS based on the screen's resolution and size

Currently, I am working with a client who needs interfaces to be adapted for two screens with a resolution of 2560x1600. The challenge is that both screens have the same resolution but different screen diagonals. One has a 27" diagonal and the other... on ...

When trying to include an external class that extends Pane in a main class in JavaFX, simply adding it may not achieve the

My primary class is as follows: public class Digital_Analog_Clock_Beta_1 extends Application { @Override public void start(Stage primaryStage) { double outerBoxWidth = 500, outerBoxHeight = outerBoxWidth / 2.5; Rectangle outerB ...

How to reduce the default width of Bootstrap carousel components

Click here for the 1st image. To view the 2nd image, click here. This represents the carousel code used on this particular website: <div class="row testing"> <div id="carouselExampleMen" class="carousel carousel-dark s ...

Ways to continuously monitor a div for a specific class

Is there a way to continuously check if an area has the class "top-nav" in order for the alerts to work every time it lacks or contains the class? How can I achieve this functionality? Check out the code on jsfiddle: https://jsfiddle.net/jzhang172/117mg0y ...

Ways to match a string against a numeric value

I have a span id with textContent which have their own time(hour/minutes) <div class="here"> <span class="time" >8 min</span> </div> <div class="here"> <span class="time" >22 min&l ...

What are the benefits of utilizing the useStyles MaterialUI function instead of traditional CSS?

As I develop my MERN application, I am utilizing Material UI components along with inline attributes. However, I find myself questioning the necessity of creating a JavaScript file just to import the makeStyles function, which essentially outputs an obje ...

My form does not receive the Bootstrap classes when using the jQuery script

**Why isn't my jQuery script coloring the rows as expected when certain conditions are met (I italicized the specific part of the code)?** Here is the HTML CODE for the POLL: <form id="pollForm" class="mb-4"> <d ...

Access the style of the first script tag using document.getElementsByTagName('script')[0].style or simply refer to the style of the document body with document.body.style

Many individuals opt for: document.getElementsByTagName('script')[0].style While others prefer: document.body.style. Are there any notable differences between the two methods? EDIT: Here's an example using the first option: ...

Is it possible to change the style of the current page in PHP using the ?page href method?

Currently, I am facing an issue with styling in my code. Specifically, I want to style the page numbers that are currently open or active. For example, if a page is open, I would like its corresponding number to be displayed in a different color or style. ...

The hamburger menu in Bootstrap collapses along with the navigation items when viewed on a mobile device

How can I resolve the issue of the hamburger menu icon collapsing with the nav-items when clicked? Navbar <header> <div class="container-fluid"> <div class="row"> <div class="col-12 col-sm-12"> ...