Я собираюсь поместить кнопку удаления в div, чтобы пользователь нажал кнопку delete, после чего div будет удален. Но в настоящее время существует 2 проблемы.Событие Click не работает в contenteditable div
(1) Кнопка я размещаемая не выровнен с текстом в DIV
(2) Клик событие кнопки не работает.
Пожалуйста, смотрите мой HTML
$("#slider").on("change",function(){
var v=$(this).val();
$('.text.active').css('font-size', v + 'px');
});
$('.text').on('focus',function(){
$('.close-icon').addClass('active');
\t $('.text').removeClass('active');
\t $(this).addClass('active');
});
$(".close-icon.active").on("click",function(){
alert('hiii');
});
.close-icon {
\t border:1px solid transparent;
\t background-color: transparent;
\t display: inline-block;
\t vertical-align: middle;
outline: 0;
cursor: pointer;
}
.close-icon:after {
\t content: "X";
\t display: block;
\t width: 15px;
\t height: 15px;
\t position: absolute;
\t background-color: #FA9595;
\t z-index:1;
\t right: 35px;
\t top: 0;
\t bottom: 0;
\t margin: auto;
\t padding: 2px;
\t border-radius: 50%;
\t text-align: center;
\t color: white;
\t font-weight: normal;
\t font-size: 12px;
\t box-shadow: 0 0 2px #E50F0F;
\t cursor: pointer;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="range" min="12" max="120" id="slider" />
<div class="text" contenteditable="true" style="cursor:grab;">hello<button class="close-icon dbutton" type="reset"></div>
<div class="text text1" contenteditable="true" style="cursor:grab;">hello<button class="close-icon dbutton1" type="reset"></div>
<div class="text text2" contenteditable="true" style="cursor:grab;">hello<button class="close-icon dbutton2" type="reset"></div>
<div class="text text3" contenteditable="true" style="cursor:grab;">hello<button class="close-icon dbutton3" type="reset"></div>
Пожалуйста, помогите решить эту проблему.
На щелчке кнопки удаления последней DIV будет удалена? –
Что я понимаю, вы хотите скрыть все div, когда вы нажимаете красную кнопку внизу справа на вашей странице, или? – enucar