[Solved] How to determine if the user is 18 years old and up using jquery?

Try this: Jquery: $(‘#datepicker’).datepicker({ onSelect: function(value, ui) { var today = new Date(), age = today.getFullYear() – ui.selectedYear; if(age >= 18) $(‘#age’).text(“User is 18 years old”); else $(‘#age’).text(“User is 18 not years old”); }, maxDate: ‘+0d’, changeMonth: true, changeYear: true, yearRange: ‘-110:-30’ }); Html: <input type=”text” id=”datepicker” /> <div id=”age” /> 5 solved How to … Read more

[Solved] Remove parent JSON element depending on child value

Well, I found a way to iterate through the JSON object: function remove(jsondata) { for (let i in jsondata) { if (jsondata[i].value != undefined && jsondata[i].value == ”) { delete jsondata[i]; } else if (typeof jsondata[i] === “object”) remove(jsondata[i]); } } Not sure, if it’s the most elegant way, but it works so far. 1 … Read more

[Solved] Remove text that starts with [closed]

You could use the following regex to replace from the first – character and any characters there after. $(“.colsborder h3″).each(function(){ var str = $(this).text(); var replaced = str.replace(/-.*/, ”); $(this).text(replaced) }); <script src=”https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js”></script> <div class=”colsborder”> <h3>Startoftext-needtoremove</h3> </div> This method would be faster than using the substring or split methods. 1 solved Remove text that starts … Read more

[Solved] How I can showing div element after I hover another div? [closed]

You can solve this without JS, with pure css. HTML <div id=”button”> hover me </div> <div id=”my-menu”> my menu </div> CSS #my-menu, #button{ padding: 5px; border: 1px solid #000; } #my-menu{ display: none; } #button:hover + #my-menu, #my-menu:hover{ display: block; } Here is a JSFiddle: http://jsfiddle.net/p8pqquc9/ You will have a problem with this solution, if … Read more

[Solved] Save value of a drop-down list and reassign it

var lastValue; $(‘#qty’).live(‘change’, function () { if ((this.value) == 10) { $(this).replaceWith($(‘<input/>’, { ‘type’: ‘text’, ‘value’: +(this.value) })); } else{ lastValue = this.value; } }); And then use lastValue to reset the value of the selectbox when you have to show it. EDIT : modified the jsfiddle, you jsut need to create the list again … Read more

[Solved] Find an easy web server framework for mobile game [closed]

You should try out Firebase (https://www.firebase.com/) if you’re looking for something relatively easy to store game data with. If you’re looking for something to manage logins and storing simple data, either Twitter’s Fabric (https://get.fabric.io/) and AWS Cognito (https://aws.amazon.com/cognito/) can also be used as well 2 solved Find an easy web server framework for mobile game … Read more

[Solved] How to disable / enable checkbox base on select (option) value [closed]

All you have to do is listen to the select and react when it changes. // Listen to the change of the <select> element $(“#typeofworkday”).on(“change”, function() { // Check the option value for “ferie” and disable the checkbox if ($(this).val() === “ferie”) { $(“#check1”).attr(“disabled”, “disabled”); // For all other options, enable the checkbox } else … Read more

[Solved] Looking for a well written inifite scroll plugin [closed]

For infinite scrolling you should do ajax to load more content in your page each time when scroller hits the bottom of the page. $(window).scroll(function() { if($(window).scrollTop() + $(window).height() == $(document).height()) { angular.element(“#yourControllerId”).scope().loadMore(); } }); // angularJs code $scope.loadMore = function(){ // do ajax } solved Looking for a well written inifite scroll plugin [closed]

[Solved] Creating objects by splitting an object whose attributes are arrays [closed]

Using flatMap you can ungroup the elements in an array.. const fruit=”apple” const array=[ { names:[‘something1’, ‘something2’], fruit: fruit, features:[‘feature1′,’feature2’] } ] array.flatMap(({names,fruit,features}) => { names.flatMap(name => { features.flatMap(feature => { console.log(({name,fruit,feature})); }) }) }) 5 solved Creating objects by splitting an object whose attributes are arrays [closed]

[Solved] How to change form background color on focus loss when text is entered?

blur is what you are looking for. document.write(“<input type=”text”>”); var input = document.querySelector(‘input’); input.addEventListener(‘focus’,function(){ input.style.backgroundColor = “purple”; }) input.addEventListener(‘blur’,function(){ if(input.value != “”){ input.style.backgroundColor = “green”; } }) 0 solved How to change form background color on focus loss when text is entered?