Skip to content

Author: admin@master

JS Set background image of span

JS: HTML: I was wondering if it would be possible to also set the source of an image in this HTML from my Javascript code. So if I get “Item One” it will display that image in my HTML? Answer You just need to create an array containing the paths to your images such as var images = [“image1.p…

PURE JS get selected option data attribute value returns Null

I have this html: and js but it always alerts null instead of data value Where is the problem guys? Thanks Answer The problem is that you get select element and not selected option element as function argument. And it does not have the data attribute. You have to get the option attribute like so: Notice that …

HTML5 Canvas Javascript how to make smooth brush

Hello i need make smooth brush likes this: I try to create it, i make circle and fill it, but result not successful: Can be seen circles.. this is not smooth like first example my example code: http://codepen.io/anon/pen/NPjwry Answer Try with a smaller globalAlpha and decrease the stepping (so you draw more …

What is the difference between state and props in React?

I was watching a Pluralsight course on React and the instructor stated that props should not be changed. I’m now reading an article (uberVU/react-guide) on props vs. state and it says Both props and state changes trigger a render update. Later in the article it says: Props (short for properties) are a C…

Converting base64 to blob in javascript

I tried to convert a JPEG’s base64 string to a blob on a Cordova/hybrid app running on iOS 8 using the following function b64toBlob. However it’s giving an error when we do How can be work around this error? Answer Try this out. Please note that dataURI is assumed to include base64 prefix. (e.g. &…