[Solved] Javascript uncaught syntaxerror unexpected identifier error

In this line htmlStr += ‘<a id=”searchResult’+i+'” href=”https://stackoverflow.com/questions/29555599/javascript:liveSearch(“+arrOfSuggestText[i]+’)” > ‘+arrOfSuggestText[i]+'</a>’; and concrete here ‘” href=”https://stackoverflow.com/questions/29555599/javascript:liveSearch(“+arrOfSuggestText[i]+’)” > ‘ you try create calling function, but if you see value of this string, for arrOfSuggestText[i] == ‘qwe’ you can see something like href=”https://stackoverflow.com/questions/29555599/javascript:liveSearch(qwe)” and browser raise error what you get on qwe. So you need just add quotes … Read more

[Solved] How to create checkbox looks like font-awesome glyphicon

You can do achieve this even without Javascript. #checkbox{ background:#2f8cab; display:inline-block; padding:15px 18px; border-radius:2px; position:relative; cursor:pointer; } #checkbox-element{ display:block; position:absolute; left:0; top:0; width:100%; height:100%; z-index:99999; opacity:0; } #checkbox>input[type=”checkbox”]+i{ color:rgba(255,255,255,0.2); // color 1 } #checkbox>input[type=”checkbox”]:checked+i{ color:#fff; //color 2 } And here’s the markup, <span id=”checkbox”> <input id=”checkbox-element” type=”checkbox”/> <i class=”glyphicon glyphicon-check”></i> </span> Have a look at … Read more

[Solved] How to change audio tag when I click on radio button?

Updated: <!DOCTYPE html> <html> <head> <title>Events</title> </head> <body> <input type=”radio” value=”test2″ name=”rad” onclick=”boom(this.value);”>test2 <input type=”radio” value=”test3″ name=”rad” onclick=”boom(this.value);”>test3 <input type=”radio” value=”test4″ name=”rad” onclick=”boom(this.value);”>test4 <br> <audio id=”audio” controls> <source src=”” type=”audio/ogg”> <source src=”” type=”audio/mpeg”> <source src=”https://stackoverflow.com/questions/37552235/test1.wav” type=”audio/wav” id=”sound”> </audio> <script type=”text/javascript”> function boom(val){ var audio = document.getElementById(“audio”); var aud = document.getElementById(“sound”); aud.src=val+”.wav”; audio.load(); } </script> </body> … Read more

[Solved] replace array of object with another array of object base on property

You can do it using Array#map() to create a new array and Array#find() to find the object in the second array let arr=[{status:”ok”},{status:”ok”},{status:”error”}], arr2=[{status:”error”,msg:”etc”,”more property”:!0}]; arr = arr.map(a=>{ let fullObj = arr2.find(a2=>a2.status===a.status); return fullObj ? fullObj : a; }); console.log(arr); 3 solved replace array of object with another array of object base on property

[Solved] Change date format from dd-mm-yy to ddmmyy

Or you can use string split method also. check the working demo. var yourDate = “11-12-2014”; getDate(yourDate); function getDate(yourDate){ var date = yourDate.toString(); var divide = date.split(‘-‘); var newDate = divide[0]+divide[1]+divide[2]; alert(newDate); } 1 solved Change date format from dd-mm-yy to ddmmyy

[Solved] Javascript scoping change

The following excerpts are taken from ECMA-262 7th edition (ECMAScript 2016) – section numbers sometimes differ between versions. 18.2.1.1 Runtime Semantics: PerformEval( x, evalRealm, strictCaller, direct) … 9. If direct is true, then a. Let lexEnv be NewDeclarativeEnvironment(ctx’s LexicalEnvironment). b. Let varEnv be ctx’s VariableEnvironment. 10. Else, a. Let lexEnv be NewDeclarativeEnvironment(evalRealm.[[GlobalEnv]]). b. Let varEnv … Read more

[Solved] need help to understand complex javascript reg exp

The given regex is a combination of multiple regex, keep in mind that you can break this complex regex into multiple smaller one, and each smaller one can be easily translated Refer to this wiki page for finding the meaning of each small regex parts http://en.wikipedia.org/wiki/Regular_expression Your regex can be broken into /^ Start of … Read more