JSFiddle - React, Tailwind, and code Playground

by Luke Marlow

HTML

<p>Search for</p>
<input type="text" name="search" class="search" id="search" value="jpr">
<p>In String</p>
<input type="text" name="within" class="within" id="within" value="abcdefghijklmnopqrstuvwxyz">
<p><button id="button">Check</button></p>
<div id="output"></div>

CSS

input{width:300px}
#output{height:100px;width:300px;background:white;border:solid 1px #c3c3c3}

JavaScript

function clickHandler() {
    var search = document.getElementById('search').value,
        within = document.getElementById('within').value;

		var output = within.indexOf(search) != -1 ? 'contained' : 'not-containd';

		document.getElementById('output').innerHTML = output;
}

var el = document.getElementById('button');
el.addEventListener('click', clickHandler);