+ 3
How to Replace Some Specific words in webpage with javascript
Here is a code in my webpage; <div class="class_1"> <p>Copyright © 2017. Created by <a href="http://facebook.com/example123" target="_blank">Example 123</a>. Powered by <a href="http://www.example123.com" target="_blank">ExamPleXYZ</a>.</p> </div> Now is want to change 2017 into 2018 and Example 123 into change123 and ExampleXYZ into changexyz Note: only Use javaScript not jquery
3 Antworten
+ 2
Hello there
try this
<!DOCTYPE html>
<html>
<body>
<div class="class_1"> <p>Copyright © <script>document.write(new Date().getFullYear())</script>. Created by <a href="http://facebook.com/example123" target="_blank">Example 123</a>. Powered by <a href="http://www.example123.com" target="_blank">ExamPleXYZ</a>.</p> </div>
<script>
var txt=document.querySelectorAll(".class_1 p")[0];
txt.innerHTML=txt.innerHTML.replace('Example 123','change123').replace('ExamPleXYZ','changexyz');
</script>
</body>
</html>
+ 2
thanks bro
0
In simple terms. Select element by id/tag/class then change the thing you wanted to by id_of_var.thing_needs_tobe_changed = by copying the original but change the specific thing that you wanted to.