/stringRoller.js

One string is changed to other by randomly generating characters.

Primary LanguageJavaScript

StringRoller.js

Demo

https://amitad16.github.io/stringRoller.js/

Dependencies

No dependacies! Written in plain javascript.

Syntax

StringChange(selector, { finalText: Some string }).roll();

Use

<p id='stringRoller'>What is this?</p>
<button type='button' id='roll'>Roll It</button>
window.onload = () => {
  let rollBtn = document.querySelector("button#roll");
  rollBtn.addEventListener("click", () => {
    StringChange("#stringRoller", {
      finalText: "This is StringRoller.js"
    }).roll();
  });
};

Full Example

<html>
<head>
	<title>StringRoller.js</title>
</head>
<body>
	<p id='stringRoller'>What is this?</p>
	<button type='button' id='roll'>Roll It</button>

	<script src="./src/stringRoller.js"></script>
	<script>
		window.onload = () => {
			let rollBtn = document.querySelector("button#roll");
			rollBtn.addEventListener("click", () => {
				StringRoller('#stringRoller', { finalText: "This is StringRoller.js" }).roll();
			});
		}
	</script>
</body>
</html>

Options

{
  // Mandatory options
  finalText: 'Some text', // String to change to
}

Licence

Licensed under the MIT license.