Menulis di teks editor

Bagaimana cara agar tag seperti <head><body> berwarna
avatar ridzkyrabbani

@ridzkyrabbani

1 Kontribusi 0 Poin


Jawaban

Pakai code highlighter, seperti :
1. Codemirror. dll (anda bisa mencari di google menggunakan kata kunci "code highlighter").

Contoh penggunaannya :
<html>
<head>
<link rel="stylesheet" href="lib/codemirror.css">
<script src="lib/codemirror.js"></script>
<script src="lib/codemirror_jsx.js"></script>
</head>
<body>
<textarea id="code" name="code">
<script>
function colorcoding() { 
   var ua = navigator.userAgent; 
   //Opera Mini refreshes the page when trying to edit the textarea. 
   if (ua && ua.toUpperCase().indexOf("OPERA MINI") > -1) { return false; } 
   window.editor = CodeMirror.fromTextArea(document.getElementById("code"), { 
   mode: "text/html", 
   htmlMode: true, 
   lineWrapping: true, 
   smartIndent: false, 
   addModeClass: true 
   }); 
  // window.editor.on("change", function () {window.editor.save();}); 
  } 
  colorcoding();
</script>
</body>
</html>

Semoga membantu.
avatar syahid246

@syahid246

70 Kontribusi 160 Poin


Login untuk gabung berdiskusi