“input jelas” Kode Jawaban

Hapus Input Fild

document.getElementById('inpu').value = ''

<input type="text" onfocus="this.value=''" value="Blabla">
Xanthous Xenomorph

Input Jenis Pencarian Event Hapus

document.getElementById('searchInput').addEventListener('input', (e) => {
  console.log(`Input value: "${e.currentTarget.value}"`);
})
Agreeable Anaconda

input jelas

document.getElementById("msg").value = "";
GutoTrosla

Tambahkan Tombol Hapus ke Input Teks

<input type="search" placeholder="Search..."/>

<style>
  input[type=search]::-webkit-search-cancel-button {
    -webkit-appearance: searchfield-cancel-button;
  }

  input[type=search] {
      -webkit-appearance: none;
  }
</style> 

Tambahkan Tombol Hapus ke Input Teks

<!DOCTYPE html>
<html lang="en">
    <head>
        <title>SO question 2803532</title>
        <script src="http://code.jquery.com/jquery-latest.min.js"></script>
        <script>
            $(document).ready(function() {
                $('input.deletable').wrap('<span class="deleteicon" />').after($('<span/>').click(function() {
                    $(this).prev('input').val('').trigger('change').focus();
                }));
            });
        </script>
        <style>
            span.deleteicon {
                position: relative;
            }
            span.deleteicon span {
                position: absolute;
                display: block;
                top: 5px;
                right: 0px;
                width: 16px;
                height: 16px;
                background: url('http://cdn.sstatic.net/stackoverflow/img/sprites.png?v=4') 0 -690px;
                cursor: pointer;
            }
            span.deleteicon input {
                padding-right: 16px;
                box-sizing: border-box;
            }
        </style>
    </head>
    <body>
        <input type="text" class="deletable">
    </body>
</html>

Jawaban yang mirip dengan “input jelas”

Pertanyaan yang mirip dengan “input jelas”

Lebih banyak jawaban terkait untuk “input jelas” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya