I am trying to create a function so that when user clicks on a div and then click on a button background-color of that div will change therefore value has to be saved as a variable, but I cannot seem to get it to work as all the time is says that "storage" variable is undefined. Whole page can be seen at:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="content-link2">
<title>Template 1</title>
<link href="http://localhost/fyproject/public/templates/css.css" rel="stylesheet" type="text/css">
<button class="btn btn-default form-control margin color" value="yellow">Background</button>
<button class="btn btn-default form-control margin color" value="red">Background</button>
<div class="logo">
<img class="images" id="image" src="#" alt="Your Logo">
</div>
<div contenteditable="true" id="content" class="draggable ui-widget-content refresh ui-draggable ui-draggable-handle" style="position: relative;">
<p>hlo</p>
</div>
<div id="comments">
<form name="forma">
<textarea name="commentUser" id="commentUser" class="refresh" cols="40" rows="5">Comments here...
</textarea>
<br>
<input type="submit" value="Ready!" id="send-data">
<!--onClick="writeComment(e);"-->
<div id="editTxt" class="refresh" contenteditable="true">
<p>This text can be by the user.</p>
</div>
</form>
</div>
</div>
$(document).ready(function() {
$('.color').click(function() {
$(storage).css("background-color", $(this).attr("value"));
});
});
$('#content-link2').on('click', 'div', function(e) {
var storage = ($(e.target).attr("id"));
});
Page can be seen at: