[Solved] How to read nested json object? [duplicate]

Simply do it by myObj.cars.car1 , myObj.cars.car2 and , myObj.cars.car3 to get directly or loop as below example var myObj = { “name”: “John”, “age”: 30, “cars”: { “car1”: “Ford”, “car2”: “BMW”, “car3”: “Fiat” } }; for (let i in myObj) { if (typeof myObj[i] == ‘object’) { for (let j in myObj[i]) { console.log(j, … Read more

[Solved] How can I use an alert or form input to allow a user to set a value of a CSS parameter [closed]

JSFiddle Use the prompt function and assign its return value via element.css() $(‘#btn’).click(function(e){ var w=prompt(“Enter new hue:”,””); $(‘#box’).css(‘-webkit-filter’,’hue-rotate(‘+w+’deg)’); }); 0 solved How can I use an alert or form input to allow a user to set a value of a CSS parameter [closed]

[Solved] jquery if background is red doesn’t recognize error, looks easy but stubborn

Why is this fiddle not working? Many reasons. 1) CSS property background is not background-color 2) background-color is not red but rgb(255, 0, 0) Working code: $(document).ready(function(){ $(“.box”).click(function(){ if ($(“.box”).css(“background-color”) == “rgb(255, 0, 0)”) { $(“.box”).html(“Success!”); } }); }); Working Jsfiddle link Side note: debugging with console.log() is much more convenient than alert() Side note … Read more

[Solved] jQuery hover does not work

You declared your javascript in the middle of the page and did not encase it in a document ready. So the code never binds to the specified elements. Try and be much more descriptive when asking a question. We shouldn’t have to find what file the javascript code is in nor guess based on your … Read more

[Solved] Targeting anchor tag to div tag in same page

If you want to use jQuery then you can do this: <ul id=’mainTabs’> <li><a href=”https://stackoverflow.com/questions/28454221/music_details.jsp”>Music</a></li> <li><a href=”dance_details.jsp”>Dance</a></li> </ul> then you can do this in jQuery: $(‘#mainTabs a’).click(function(e){ e.preventDefault(); $(‘#div_displayfrom’).load(this.getAttribute(‘href’)); }); 1 solved Targeting anchor tag to div tag in same page

[Solved] json object value to select dropdown update using jquery

Further @Rory McCrossan comment, A. You need tun each on the dropDownField.roles not on dropDownField. B. You can “collect” the html for each item in the array, then append it to the select. var roles = { “roles”: [{ “role_id”: 2, “role_name”: “admin” }, { “role_id”: 4, “role_name”: “QA” }, { “role_id”: 3, “role_name”: “TL” … Read more

[Solved] if statement based on Label tekst [closed]

Well, what is label? Does it have a text property? If you’ve identified the <label> element using a jQuery selector, you can get the text therein with the text() function. Something like this: <label>This Text</label> <script type=”text/javascript”> var label = $(‘label’); if (label.text() === ‘This Text’) { alert(‘hi’); } </script> Example here. 3 solved if … Read more

[Solved] Delete HTML elements with JS. WORKING JSFIDDLE [duplicate]

Insert all your code inside a div(it’s easier this way), and use a delegated event handler: $(‘#addEnv’).click(function() { var parentDiv = $(‘<div/>’, { class : ‘parentDiv’, html : ‘<div class=”col-sm-5 top10″><div class=”input-group”><label class=”input-group-addon”>Name</label><input id=”envName” class=”form-control” name=”envName” type=”text” placeholder=”e.g. name1″ /></div></div>’ + ‘<div class=”col-sm-5 top10″><div class=”input-group”><label class=”input-group-addon”>Variable</label><input class=”form-control” id=”envVar” type=”text” name=”envVar” placeholder=”e.g. var1″ /></div></div><div class=”col-sm-2 top10″><button … Read more

[Solved] Why trigger function is not working?

Is that you are looking for? <script> $(document).on(“click”, “#quizresultsave”, function(){ $(this).text(“Clicked”); }); $(document).ready(function(){ $(‘#step2continue’).click(function(){ $(“#quizresultsave”).trigger(“click”); }); }); </script> <div id=”step2continue” onclick=””>test tes tes test </div> <div id=”quizresultsave” onclick=”alert(‘tt’)”>testingggggg</div> solved Why trigger function is not working?