Skip to content

Tag: javascript

Vue js – Set alt image when image source not found

I am working on a site which has a list of products. Each product has a corresponding image. I am binding the image url to the source attribute like below. If the image is not found, I want to show a default image. I do as below in cshtml razor syntax (for reference only) How do I achieve the same

Why is a Vue function not recognized when used in computed()?

The following code (a Vue method is used in a string template when the component is mounted) works: : The one below = the above expanded to use this.perc() in a computed variable, fails with TypeError: this.perc is not a function Why isn’t this.perc() available in a computed variable? Answer It must be …

How do you modify a file using JavaScript together with PHP?

I want to add text to a text document using JavaScript and PHP. What would be the best way to do this? Answer This is possible by using Javascript (front-end) to send an ajax request to the PHP server script that does the operation (back-end). What you can do is use jQuery.ajax or XMLHttpRequest. XMLHttpReque…

How to create image scrolling parallax effect with CSS?

I saw this cool scrolling effect online… Where the image blends with the next image when scrolling through sections. I’ve been trying to reproduce it, but I can’t seem to figure it out? How can I create this effect on the web? Here is the link to where I saw the effect… http://readingb…

How to reset form radio buttons to unchecked in reactjs?

I have made 4 radio buttons for 1 question. I have made 2 buttons submit and clear input. When I submit the form after clicking on clear input it does not clear the checked buttons to unchecked how can I do that using reset function ? contactform.js: See screenshots: Answer Give a checked attribute for you ra…

Returning data from Axios API [duplicate]

This question already has answers here: How do I return the response from an asynchronous call? (41 answers) Closed 3 months ago. I am trying to use a Node.JS application to make and receive API requests. It does a get request to another server using Axios with data it receives from an API call it receives. T…

How do I retrieve text from user selection in pdf.js?

This question is specific to pdf.js, a javascript based pdf renderer. I’m building a custom version where I need to extract the text that I select inside the pdf. There are other posts where you can fetch the text from one page or the whole pdf document such as the one here , but I’m looking to gr…

Is it possible to limit text selection to current element?

Is it possible (by any HTML node, CSS or JS) to prevent from selecting text in div.item2 if selection started from text in div.item1 and the other way around – starting from div.item2 and limit to it (prevent item1 form being selected)? Answer I came up with this, with a bit of jQuery code :