Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript.void(0);

<a href="javascript:void(0)" id="top">Top</a>
Comment

javascript.void(0)

The void operator evaluates the given expression and then returns undefined.

The void operator is often used merely to obtain the undefined primitive value,
usually using “void(0)” (which is equivalent to “void 0”). In these cases,
the global variable undefined can be used instead (assuming it has not been
assigned to a non-default value).

An explanation is provided here: void operator.

The reason you’d want to do this with the href of a link is that normally,
a javascript: URL will redirect the browser to a plain text version of the
result of evaluating that JavaScript. But if the result is undefined,
then the browser stays on the same page. void(0) is just a short and
simple script that evaluates to undefined.
Comment

PREVIOUS NEXT
Code Example
Javascript :: storing jason format in perl and retriving it 
Javascript :: javascript replace char if not present another character 
Javascript :: moment js formating to one day less using zulu time 
Javascript :: js array equals ignore order 
Javascript :: how to swap two variable values in js 
Javascript :: using jquery to extend textarea 
Javascript :: mutiple if in express handlebars 
Javascript :: js letter animation 
Javascript :: angular table lazy loading 
Javascript :: atomic design with redux 
Javascript :: custom render contenful rich text rendering 
Javascript :: element vs node 
Javascript :: how to place text input cursor to start in react native 
Javascript :: apps script convert a1notation to row column 
Javascript :: how to save js object to clipboard 
Javascript :: Raphael JS store arbitrary data 
Javascript :: click to enlarge in javascript 
Javascript :: rebuild package-lock.json 
Javascript :: useEffect not working array changes 
Javascript :: object mapper pretty write as string 
Javascript :: add operator in javascript 
Javascript :: react and express 
Javascript :: Callback after forEach completed 
Javascript :: javascript get distance bwetween elements 
Javascript :: object.keys map 
Javascript :: jabascript for each 
Javascript :: javascript intersect two object arrays 
Javascript :: how to manually sort array javascript 
Javascript :: uplaod file in s3 from heroku for node js 
Javascript :: prepare webpack-ready 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =