How can I implement a reset of the entered data within the input itself? For example, add a cross to the right, when clicked, which resets the entered values. I can make a button next to reset, but I do not know how to put a cross inside. I don't need to add an icon, I just need a standard cancel.
- 3Possible duplicate question: How to insert an icon in the input - Air
- Below there is an easier way to add a reset - Denis Evceev
- Possible duplicate question: How to insert a font into the input? - αλεχολυτ
- Are you kidding me? What a duplicate - Denis Evceev
|
3 answers
You can use input type="search"
<input type="search"> Well, if you need through js
x-field{ display:inline; position:relative; } x-field .close { position:absolute; padding:0 5px; right:0; } <x-field> <input type="text" id = "text"> <span class="close" onclick="this.previousElementSibling.value = ''"> × </span> </x-field> - i.stack.imgur.com/YPQkc.png - andreymal
- I do not know what you have, caniuse.com/#feat=input-search - ishidex2
- "1 - Does not use a special search-specific UI for the field" - this is what I have) - andreymal
- it seems yes, it is necessary to stylize - ishidex2
|
var input = document.querySelector('input'); input.addEventListener('click', function(event) { event = event || window.event; if (event.offsetX < 51) { input.value = ''; } }) input.addEventListener('mousemove', function(event) { event = event || window.event; if (event.offsetX < 51) { input.style.cursor = 'pointer'; }else{ input.style.cursor = 'text'; } }) @import "http://fonts.fontstorage.com/import/adventpro.css"; * { margin: 0; padding: 0; } html, body { width: 100%; height: 100%; background-color: #065b79; overflow: auto; } input { position: absolute; top: 100px; left: 100px; height: 50px; width: 400px; padding-left: 55px; background-color: transparent; background-image: url(http://nouveal.com/wp-content/themes/html5blank-stable-nouveal/img/croix@2x.png); background-repeat: no-repeat; outline: none; color: #fff; text-align: left; font-size: 35px; font-family: 'Advent'; border: 0; border-bottom: .1px solid #fff; } input::placeholder { color: #fff; text-align: center; } <input type="text" placeholder="FiFa"> |
You can try to set the parent to a position different from static , for example, position:relative , and to the position:absolute button and with the help of left , right , top , bottom place it where necessary.
Look here
|