I want to be able to create a input field where you can enter CSS and have that input value and only that input value be applied to the page.
You can apply any amount of input values to the page and each time it will reset the previous.
Here is what i tried, and it works except for the part where i'm trying to reset the css so i've commented that line out (.remove).
$('input').on('change', function(){
//$('style')[1].remove();
var input = $('input').val();
var style = $('<style>span'+ input +'{background:yellow }</style>')
$('html > head').append(style);
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input value=":nth-child(3)">
<span>1</span>
<span>2</span>
<span>3</span>
<span>4</span>
<span>5</span>
<span>6</span>
<span>7</span>
<span>8</span>
<span>9</span>
<span>10</span>
<style>element, why not try DOM traversal and the.css()method?