Skip to content

Category: Questions

import JSON file with node.js

I want data from the config.json file import to the index.js file in the same dir. so I had it before now i would change the string so i need a json object, but how? Answer In ES5 you can do it by The object will contain your JSON. In ES6 Using fs module synchronously

Changing input button to images

I am new to JavaScript. I am having trouble changing the show button and hide button to images instead. The show button will be a different image to the hide button. How would I go about doing this? https://jsfiddle.net/ej0r4amd/2/ Answer Since you’re using jQuery, you can use the <input type=”…

Three.js Zoom-to-Fit with offset

I’m trying to come up with a zoom-to-fit function that ensures that a list of points are perfectly fit into the drawing area, while also adding configurable offsets on all sides of the image. I.e. zoom-to-fit an area of the frame rather than the whole viewer area: (note that the offsets in this image ar…

getSelection().focusNode inside a specific id doesn’t work

I have code to bold/unbold scripts via Window.getSelection() I got it from this answer: Bold/unbold selected text using Window.getSelection() It really works without problems . But when I looked for another code to make the selection inside a div specified with id I found this answer : How to getSelection() w…