[英]How to highlight a contentEditable span on glyphicon click
I have 2 spans 我有2个跨度
<span contentEditable=true class="editspan"></span>
<span class="pencilspan glyphicon glyphicon-pencil pull-right"></span>
and a js function 和一个js功能
$(document).on('click', '.pencilspan', function () {
console.log("clicked pencil");
});
What I want is when I click on pencilspan the contentEditable area of editspan should get highlighted(input box should be visible). 我想要的是当我点击pencilpan时,editspan的contentEditable区域应该突出显示(输入框应该是可见的)。 How can I achieve this? 我怎样才能做到这一点?
Please try this might help you if you are looking for toggle: 如果您正在寻找切换,请尝试这可能会对您有所帮助:
<!DOCTYPE html>
<html>
<head>
<style>
.editInput{
display:none;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
</head>
<body>
<span contentEditable=true class="editspan">
<input type = 'text' value ='' class='editInput' />
</span>
<span class="pencilspan glyphicon glyphicon-pencil pull-right">button</span>
<script>
$(document).ready(function(){
$(document).on('click', '.pencilspan', function () {
// var editInput = "<input type = 'text' value ='' />";
$('.editspan .editInput').toggle();
});
});
</script>
</body>
</html>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.