if function not exectuiing
Hello guy, I'm new here. My problem is i have a few functions on my <script tag> : a POST, GET and a function which is supposed to change a buttons text if the true condition is met. Everything works except for the if statement(the last function). I Have been trying to resolve it but no luck. It's not executing. Here is the code:
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8" />
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <title>demo</title>
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
- <script src="https://code.jquery.com/jquery-3.1.1.js"></script>
- <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
- </head>
- <body>
- <button id="b" type="button" class="btn btn-success"></button>
- <script>
- json = {
- "variations": {
- "data": [
- {
- "is_color": true,
- "items": [
- {
- "pk": 2,
- "name": "Red",
- "hex_code": "ff0000"
- },
- {
- "pk": 1,
- "name": "Black",
- "hex_code": "000000"
- }
- ],
- "name": "Color"
- },
- {
- "is_color": false,
- "items": [
- {
- "pk": 6,
- "name": "Large (L)?",
- "hex_code": null
- }
- ],
- "name": "Size"
- }
- ],
- "check": true
- }
- };
-
- console.log(json.variations.check);
-
- // nothing down here is working
- if(json.variations.check){
- console.log("working ");
- $("#b").prop('value', 'Save');
- //$("#b").addClass('btn btn-warning');
- }
- console.log(json.variations.data);
- </script>
- </body>
- </html>