ما عليك سوى إدخال الرمز واستخدم JS للتحكم في الإدراج في موضع المؤشر.
يتم استخدامه عند تنفيذ إدخال التعبيرات.
نسخة الكود كما يلي:
<span style = "font-size: 18px ؛"> <html>
<head>
<script type = 'text/javaScript'>
اختبار الوظيفة (str) {
var tc = document.getElementById ("mytextarea") ؛
var tclen = tc.value.length ؛
tc.focus () ؛
إذا (typeof document.selection! = "undefined")
{
document.selection.createRange (). text = str ؛
}
آخر
{
tc.value = tc.value.substr (0 ، tc.selectionStart)+str+tc.value.substring (tc.selectionStart ، tclen) ؛
}
}
</script>
</head>
<body>
<TextArea Rows = 5 Name = S1 cols = 27 id = "mytextarea"> الغرض: إدراج نص عند توقف المؤشر في Textarea بالنقر فوق الزر على الزر على الصفحة </textarea>
<نوع الإدخال = زر OnClick = "Test ('هذا هو النص الذي يجب إضافته") />
</body>
</html>
</span>