here is my fiddle: http://ift.tt/2tGGKdM it isn't making much for some odd reason. I am trying to turn only the ingredients into checkboxes and once that's working I want to loop the whole thing 3 times.
HTML
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1">
<link rel="stylesheet" href="../../resources/css/style.css">
<link rel="stylesheet" href="http://ift.tt/2g6N0YS">
<link rel="stylesheet" href="../../resources/css/flexboxgrid-6.3.1/css/flexboxgrid.min.css">
<link rel="shortcut icon" type="image/x-icon" href="../../favicon.png" />
<script type="text/javascript" src="../../resources/libs/jquery/jquery-2.2.4.min.js"></script>
<script type="text/javascript" src="../../resources/script/main.js"></script>
<script type="text/javascript" src="../../resources/libs/bootstrap-3.3.6-dist/js/bootstrap.js"></script>
<!--<script async defer src="http://ift.tt/2u9D8od"></script>-->
<!--<script type="text/javascript" src="../../resources/script/googleMaps.js"></script>-->
<title>Dinner Party</title>
</head>
<body>
<div class="mainContainer col-md-12 col-xs-12">
</div>
</body>
JS
var main = function () {
var $checkBoxes = document.createElement('div');
$checkBoxes.setAttribute("class", "checkBoxes");
var $recipePicContainer = document.createElement('span');
$recipePicContainer.setAttribute("class", "recipePicContainer");
function makeRecipePic(){
var recipe = document.createElement("IMG");
recipe.setAttribute("src", "../images/grasshopper-cocktail.jpg");
recipe.setAttribute("class", "recipe");
$recipePicContainer.appendChild(recipe);
}
makeRecipePic();
var mainContainer = document.getElementsByClassName('mainContainer');
mainContainer[0].appendChild($checkBoxes);
var $div = document.createElement('div');
$div.innerHTML = 'CockTails';
$recipePicContainer.appendChild($div);
$checkBoxes.appendChild($recipePicContainer);
var $recipes = document.createElement("ul");
var $checkboxes = document.getElementsByClassName('checkBoxes');
//var x = document.createElement("INPUT");
//x.setAttribute("type", "checkbox");
for (var i = 1; i <= 6; i++) {
var li = document.createElement("li");
li.className = "ingredients";
li.setAttribute("type", "checkbox");
var a = document.createElement("a");
a.innerHTML = "Ingredient " + i;
li.appendChild(a);
$recipes.appendChild(li);
}
var b = document.createElement("li");
li.innerHTML = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.";
li.className = "Instructions";
$checkboxes[0].appendChild($recipes);
$('.recipes').hide();
$('.mainContainer .recipePicContainer').click(function () {
$(this).next('ul').toggle("slow").toggleClass('selected');
});
};
$(document).ready(main);
Aucun commentaire:
Enregistrer un commentaire