Trending questions in Java-Script

0 votes
1 answer

How to test if a string is JSON or not?

Hello @kartik, Use JSON.parse function isJson(str) { ...READ MORE

Oct 8, 2020 in Java-Script by anonymous
• 82,880 points
3,666 views
0 votes
1 answer

How to disable scrolling temporarily?

Hello @kartik, Do it simply by adding a ...READ MORE

Sep 18, 2020 in Java-Script by Niroj
• 82,880 points
4,451 views
0 votes
1 answer

How to open a URL in a new Tab using JavaScript or jQuery?

Hello @kartik, Use window.open(): var win = window.open('http://edureka.co/', '_blank'); if (win) ...READ MORE

Aug 25, 2020 in Java-Script by Niroj
• 82,880 points
5,467 views
0 votes
1 answer

Error: Cannot find module 'html'

Hello @kartik, You can have jade include a ...READ MORE

Sep 3, 2020 in Java-Script by Niroj
• 82,880 points
5,067 views
0 votes
1 answer

Error:Uncaught SyntaxError: Unexpected token

Hello @kartik, Using the jQuery command getJSON and ...READ MORE

Oct 9, 2020 in Java-Script by Niroj
• 82,880 points
3,459 views
0 votes
1 answer

How do I access ViewBag from JS?

Hello @kartik, in your view write : <script> var ...READ MORE

Sep 9, 2020 in Java-Script by Niroj
• 82,880 points
4,683 views
0 votes
1 answer

How to get the size of a JavaScript object?

Hello @kartik, Use this code: function roughSizeOfObject( object ) ...READ MORE

Sep 23, 2020 in Java-Script by Niroj
• 82,880 points
4,057 views
0 votes
1 answer

Error:Origin is not allowed by Access-Control-Allow-Origin

Hello @kartik, The easiest way to handle this ...READ MORE

Jun 18, 2020 in Java-Script by Niroj
• 82,880 points
8,287 views
0 votes
1 answer

Uncaught TypeError: Cannot use 'in' operator to search for '324'

Hello @kartik, You have a JSON string, not ...READ MORE

Jun 18, 2020 in Java-Script by Niroj
• 82,880 points
8,232 views
0 votes
1 answer

How can I set multiple CSS styles in JavaScript?

Hello @kartik, Using Object.assign: Object.assign(yourelement.style,{fontsize:"12px",left:"200px",top:"100px"}); This also gives you ability to ...READ MORE

Oct 8, 2020 in Java-Script by Niroj
• 82,880 points
3,184 views
0 votes
1 answer

How to catch net::ERR_CONNECTION_REFUSED?

Hello @kartik, You have access to online/offline in ...READ MORE

Jun 18, 2020 in Java-Script by Niroj
• 82,880 points
7,975 views
0 votes
1 answer

How to Obtain form input fields using jQuery?

Hello @kartik, Try this: $('#myForm').submit(function() { ...READ MORE

Sep 18, 2020 in Java-Script by Niroj
• 82,880 points
3,981 views
0 votes
1 answer

How to access PHP var from external javascript file?

Hello @kartik, You don't really access it, you ...READ MORE

Jul 6, 2020 in Java-Script by Niroj
• 82,880 points
7,165 views
0 votes
1 answer

How is the 'use strict' statement interpreted in Node.js?

Hello @kartik, "use strict"; Basically it enables the strict ...READ MORE

Oct 8, 2020 in Java-Script by Niroj
• 82,880 points
2,980 views
0 votes
1 answer

How to load local JSON file?

Hello @kartik, $.getJSON is asynchronous so you should do: $.getJSON("test.json", ...READ MORE

Aug 25, 2020 in Java-Script by Niroj
• 82,880 points
4,516 views
0 votes
1 answer

Hi, how does one kill the whatsapp message loop with a code instead of closing whatsapp-web?

Hello @Felix , Use this code: <script> function simulateMouseEvents(element, eventName) ...READ MORE

Oct 20, 2020 in Java-Script by Niroj
• 82,880 points
2,048 views
0 votes
1 answer

How to hide Bootstrap modal with javascript?

Hello @kartik, With the modal open in the ...READ MORE

Sep 3, 2020 in Java-Script by Niroj
• 82,880 points
3,943 views
0 votes
1 answer

How to center a popup window on screen?

Hello @kartik, Use this: function popupwindow(url, title, w, h) ...READ MORE

Sep 3, 2020 in Java-Script by Niroj
• 82,880 points
3,889 views
0 votes
1 answer

How do I search for a key of object in javascript?

Use hasOwnProperty(key) for (let i = 0; i ...READ MORE

Oct 14, 2020 in Java-Script by Niroj
• 82,880 points
2,083 views
0 votes
1 answer

How to change url after success in ajax without page reload?

Hello @kartik, Use the browser history to change ...READ MORE

Apr 29, 2020 in Java-Script by Niroj
• 82,880 points
9,335 views
+1 vote
1 answer

How to download a file from NodeJS Server using Express?

Hello @kartik, Express has a helper for this as: app.get('/download', function(req, ...READ MORE

Sep 23, 2020 in Java-Script by Niroj
• 82,880 points
2,893 views
0 votes
1 answer

How to use Redirect in the new react-router-dom of Reactjs?

Hello, To navigate to another component you can ...READ MORE

May 18, 2020 in Java-Script by Niroj
• 82,880 points
8,425 views
0 votes
1 answer

How to convert HTML to JSON using PHP?

Hello @kartik, If you are able to obtain ...READ MORE

Jun 19, 2020 in Java-Script by Niroj
• 82,880 points
7,047 views
0 votes
1 answer

How do I disable right click on my web page?

Hello @kartik, You can do that with JavaScript ...READ MORE

Sep 23, 2020 in Java-Script by Niroj
• 82,880 points
2,769 views
0 votes
1 answer

How to call a parent window function from an iframe?

Hello @kartik, Using Window.postMessage() This method safely enables cross-origin communication. And if ...READ MORE

Sep 3, 2020 in Java-Script by Niroj
• 82,880 points
3,574 views
0 votes
1 answer

How to send JSON data from Javascript to PHP?

Hello @kartik, PHP has a built in function ...READ MORE

Jul 6, 2020 in Java-Script by Niroj
• 82,880 points
6,050 views
0 votes
1 answer

How to add many functions in ONE ng-click?

Hello @kartik, You have 2 options : Create a ...READ MORE

Sep 4, 2020 in Java-Script by Niroj
• 82,880 points
3,417 views
0 votes
1 answer

How to stop event propagation with inline onclick attribute?

Hello @kartik, Use event.stopPropagation(). <span onclick="event.stopPropagation(); alert('you clicked inside the ...READ MORE

Sep 23, 2020 in Java-Script by Niroj
• 82,880 points
2,595 views
0 votes
1 answer

How to check Page.Validate() on client side (JavaScript) in ASP.Net?

Hello @kartik, Page_ClientValidate() will work. It returns true if ...READ MORE

Sep 9, 2020 in Java-Script by Niroj
• 82,880 points
3,126 views
0 votes
1 answer

How can I determine the type of an HTML element in JavaScript?

Hello @kartik, nodeName is the attribute you are looking ...READ MORE

Oct 8, 2020 in Java-Script by Niroj
• 82,880 points
1,872 views
0 votes
1 answer

How to get browser width using JavaScript code?

Hello @kartik, Use this code: var w = window.innerWidth; var ...READ MORE

Oct 9, 2020 in Java-Script by Niroj
• 82,880 points
1,817 views
0 votes
1 answer

How to clear cache in Yarn?

Hello @kartik, Run: yarn cache clean. Hope it helps!! Thank you! ...READ MORE

Sep 4, 2020 in Java-Script by Niroj
• 82,880 points
3,300 views
0 votes
1 answer

Which is the best Airbnb clone built with React?

Hello @rentall , For you query you can refer ...READ MORE

Oct 20, 2020 in Java-Script by Niroj
• 82,880 points
1,294 views
0 votes
1 answer

How do I use format() on a moment.js duration?

Hello @kartik, Use this: // set up let start = ...READ MORE

Oct 7, 2020 in Java-Script by Niroj
• 82,880 points
1,816 views
0 votes
1 answer

Error:React-router urls don't work when refreshing or writing manually

Hello @kartik, You can change your .htaccess file and insert ...READ MORE

Apr 27, 2020 in Java-Script by Niroj
• 82,880 points
8,783 views
0 votes
1 answer

How do you cache an image in Javascript?

Hii @kartik, You have to do three thigs: You ...READ MORE

Jun 2, 2020 in Java-Script by Niroj
• 82,880 points
7,232 views
0 votes
1 answer

Error: Unexpected token import in nodejs

Hello, Unfortunately, Node.js doesn't support ES6's import yet. To accomplish what ...READ MORE

Apr 24, 2020 in Java-Script by Niroj
• 82,880 points
8,865 views
0 votes
1 answer

How to Abort Ajax requests using jQuery?

Hello kartik, Just use ajax.abort(). For example you could ...READ MORE

Apr 27, 2020 in Java-Script by Niroj
• 82,880 points
8,730 views
0 votes
0 answers

How to generate unique ID with node.js?

This is my code: function generate(count) { ...READ MORE

Oct 9, 2020 in Java-Script by kartik
• 37,510 points
1,616 views
0 votes
1 answer

How to change an element's ID with jQuery?

Hello @kartik, Your syntax is incorrect, you should ...READ MORE

Aug 25, 2020 in Java-Script by Niroj
• 82,880 points
3,513 views
0 votes
1 answer

How to detect a 'touch screen' device using JavaScript?

Hello @kartik, Use this: function is_touch_device() { ...READ MORE

Sep 18, 2020 in Java-Script by Niroj
• 82,880 points
2,444 views
0 votes
1 answer

How to get function parameter names/values dynamically?

Hello @kartik, The following function will return an ...READ MORE

Sep 23, 2020 in Java-Script by Niroj
• 82,880 points
2,175 views
0 votes
1 answer

How can I change the page URL without refreshing the page?

Hello @kartik, This is simple you just need change ...READ MORE

Jun 18, 2020 in Java-Script by Niroj
• 82,880 points
6,281 views
0 votes
1 answer

How to change programmatically the src of an img tag?

Hello @kartik, Give your img tag an id, ...READ MORE

Sep 4, 2020 in Java-Script by Niroj
• 82,880 points
2,825 views
0 votes
1 answer

How can we access PHP variables in JavaScript or jQuery rather than <?php echo $variable ?>

Hello @kartik, You can also use json_encode for ...READ MORE

Apr 29, 2020 in Java-Script by Niroj
• 82,880 points

edited Oct 7, 2021 by Sarfaraz 8,292 views
0 votes
1 answer

How do I check if an HTML element is empty using jQuery?

Hello @kartik, Try: if ($('#element').is(':empty')){ //do something }  If you ...READ MORE

Aug 25, 2020 in Java-Script by Niroj
• 82,880 points
3,108 views
0 votes
1 answer

How to reject in async/await syntax?

Hello @kartik,  throw an Error wrapping the value, which results in ...READ MORE

Sep 23, 2020 in Java-Script by Niroj
• 82,880 points
1,806 views
0 votes
1 answer

How to Change the selected value of a drop-down list with jQuery?

Hello @kartik, With hidden field you need to ...READ MORE

Sep 9, 2020 in Java-Script by Niroj
• 82,880 points
2,413 views
0 votes
1 answer

How to convert an Object {} to an Array [] of key-value pairs in JavaScript?

Hello @kartik, You can use Object.keys() and map() to do this var obj ...READ MORE

Sep 4, 2020 in Java-Script by Niroj
• 82,880 points
2,617 views
0 votes
1 answer

How to remove all child elements of a DOM node in JavaScript?

Hello @kartik, Use modern Javascript, with remove! const parent = ...READ MORE

Sep 21, 2020 in Java-Script by Niroj
• 82,880 points
1,886 views