グリフコンをクリックすると、テキストエリアに動的に入力する機能が必要です。実際の問題を見てスニペットを使用してください検索する前にグリフコンの代わりにテキストを表示するグリフコン
$(document).ready(function(){
//Click Event of glyphicon class
\t \t $(document).on('click','.glyphicon',function(){
\t \t \t var previous_content = $.trim($("#area").html());
\t \t \t var new_icon = '<span class="'+$(this).attr('class')+'"></span>';
\t \t \t //*****The below method of create element is also not working
//var new_icon = document.createElement("span");
\t \t //new_icon.setAttribute('class', $(this).attr('class'));
\t \t \t var new_content = previous_content+new_icon;
\t \t \t $("#area").html(new_content);
\t \t
\t \t });
});
.glyphicon {
\t cursor: pointer;
}
<!DOCTYPE html>
<html>
<head>
\t <title>Test</title>
\t <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
\t <meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<textarea id="area" rows="10" cols="10"></textarea>
<p>Asterisk icon: <span class="glyphicon glyphicon-asterisk"></span></p>
<p>Copyright-mark icon: <span class="glyphicon glyphicon-copyright-mark"></span></p>
</body>
</html>
。
:
はここで働い例です。 –
テキストボックスに直接アイコンを挿入することはできません....あなたはASCII形式にしてください – sunil
@sunil:私はカスタムエディタを作っています。あなたは例を挙げていただけますか?私はそれが動作するはずだと思うので –