Search and replace text in elements.
- 0.1.0
-
7.1
-
7.0
Yes
- Squarespace plan that supports JavaScript.
-
Add code from file element text change.html to Website > Pages > Custom Code > Code Injection > FOOTER. Refer to Per-page code injection for details.
-
Read the code for any instructions within.
-
Replace [year] with result of a callback
'#block-12345678901234567890 .sqs-html-content' : { searchText : '[year]', replaceText : twcEtcYear },
Following is a very generalized example of a callback. The callback(s) must be defined before the code of this effect. Note the use of var.
<script>
var etcReplaceText = ( ) => {
console.log ( 'etcReplaceText' );
const r = 'replace text';
return ( r );
};
</script>If the element returned by a selector has event listeners this code may break the functionality of the element. Modifying something relativley simple like a text block is not likely to be an issue. Something like a gallery block or gallery section may.
Please consider making a donation.
-
2024-06-28
- initial version