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,698 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,481 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,512 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,118 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,484 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,758 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,329 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,072 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,260 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,212 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
4,028 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
8,015 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,205 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
3,013 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,546 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,064 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,981 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,923 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,369 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,100 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,092 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,905 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,438 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,794 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,625 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,098 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,483 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,621 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,857 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,152 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,898 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,314 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,309 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,835 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,277 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,808 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,783 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,903 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,626 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,534 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,473 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,205 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,303 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,842 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,312 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,137 views
0 votes
1 answer

How to trigger the window resize event in JavaScript?

Hello @kartik, Try this: window.dispatchEvent(new Event('resize') ...READ MORE

Aug 25, 2020 in Java-Script by Niroj
• 82,880 points
3,128 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,646 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,429 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,817 views