JQueryでマインドマッピングツールを構築しようとしていますが、私はdivコンテンツの編集に苦労しています。JQueryでクリック時の入力値を編集する方法
私は、(mind-container)divにテキストを追加する機能を書いています。それはうまくいく。 しかし、それが設定されたテキストを編集することはできません。ここで
は実際の例である:ここではhttps://jsfiddle.net/TiOw87/c9wwe81d/5/
は私のjQueryの機能である:
$('.mind-container').click(function(){
$('input').addClass('active');
$('input').parent().find('input').focus();
$('input').keyup(function(event){
if(event.keyCode == 13){
var string = $(this).val();
$(this).removeClass('active');
if ($(this).has("p"))
{
$(this).parent().html("<p>"+ string +"</p>")
}
else
{
$(this).parent().append("<p>"+ string +"</p>")
}
}
})
});
そして、私のHTML:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<body>
<div id='board'>
<div class='mind-container' id='mind-master'>
<input type="text">
</div>
</div>
</body>
私のことができるようにしたいと思いますdivをクリックし、すでに入力されている入力テキストの値を編集できるようにします。あなたの助けのための
おかげ
あなたのdivで 'contenteditable'属性を使用してみませんか? http://html5demos.com/contenteditableこちらをご覧ください。 https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Editable_content –