|
|
|
เขียนคำสั้งหาข้อความ แล้วให้มันเปลี่ยนสีตัวอักษร เขียนโค๊ดยังไงครับ |
|
|
|
|
|
|
|
Code (JavaScript)
<div id="datatest">ทดสอบการเปลี่ยนสีดำ ให้เป็นสีแดง</div>
<button type button onclick="changetored()" >Red Color</button>
<javascript language="javascript">
function changetored(){
var txt=document.getElementById('datatest').innerHTML;
text.innerHTML = txt.replace(/สีดำ/g, '<font color="red">สีแดง</font>');
}
</script>
เป็นตัวอย่างคร่าวนะครับ เพื่อเป็นไอเดียต่อไป
|
|
|
|
|
Date :
2014-08-11 13:42:14 |
By :
Chaidhanan |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
$txt=get_file_content('filedata'); // อาจมาจากการคิวรี่ อะไรก็ได้ เป็น text ที่ต้องการ
$search= array('คำค้น1', 'คำค้น2', 'คำค้น3' );
$target= array('แทนที่1', 'แทนที่2', 'แทนที่3' );
$txt=str_replace($search, $target, $txt);
|
|
|
|
|
Date :
2014-08-11 17:54:19 |
By :
Chaidhanan |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|