How To Make An Anchor Tag To Do Nothing?

  • modern admin logo

    StudyZone4U

  • Mega
    • News
      First slidePoster Frame PSD

      January 26, 2018

    • Drill down menu
        • Home
        • Tutorials
          • Second level
          • Second level menu
            • Third level
            • Third level
            • Third level
            • Third level
          • Second level, third link
          • Second level, fourth link
        • Latest Post
        • Interview
        • About Us
        • Contact Us
    • Tags

      Test4 Teat Test1 HTML JQuery JavaScript PHP SQL MySQL Python Django Chart Ajax PHP-MySQL TINYMCE CodeIgniter CSS CMD SSH robots_txt PayPal Elasticsearch Git Cron Job Linux htaccess Boto3 AWS KMS django-rest-framework Windows

    • Contact Us
      Name Email Message Send
How to make an anchor tag to do nothing?

Last updated 4 years, 8 months ago | 6080 views 75 5

Tags:- HTML JQuery JavaScript

HTML | Make an anchor tag to do nothing | href="javascript:void(0);"

To prevent reloading a page when a link clicked is something like preventing the default behavior of an element. It can be achieved by providing "javascript:void(0)" in "href" attribute.

<a href="javascript:void(0)">Click Here</a>

The "javascript:void(0)" make the anchor tag "href" value undefined and make its behavior as plain text.

To know more about MSD Webdock

href="#"

The anchor tag click can also be prevented by simply using "return false" in "onclick" event, like so:

<a href="#" onclick="return false;">Click Here</a>

See the Example

In the example, There is four anchor tag with each having different property and value. jump page to the top

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <!-- Refress the page --> <a href="">Click Here</a> <br> <!-- Jump page to the top --> <!-- Add # at the end of the url --> <a href="#">Click Here</a> <br> <!-- Do nothing --> <a href="#" onclick="return false;">Click Here</a> <br> <!-- Do nothing --> <a href="javascript:void(0)">Click Here</a> </body> </html>

From The Article

How to set or get config variables in Codeigniter?

Convert Object To Array in PHP

How to remove HTML tags from a string in PHP?

What is :: operator and in what case we use it in php?

Card image

hr tag attribute and its use

Card image

What is difference between require() and require_once() ?

Trending View All

How to show data values on top of each bar …

Updated 5 years ago | 38014 views

A non-numeric value encountered in PHP

Updated 5 years ago | 22841 views

The view account.views.register did not return an HttpResponse object. It …

Updated 4 years ago | 17661 views

Input type number maxlength not working

Updated 4 years ago | 16478 views

Uncaught TypeError: e.indexOf is not a function in JQuery

Updated 5 years ago | 12949 views

How to start array index from 1 in PHP

Updated 4 years ago | 12123 views

Interview Questions

PHP Interview Question
PayPal Interview Question
MySQL Interview Question
PHP-MySQL Interview Question
SQL Interview Question
CodeIgniter Interview Question
JQuery Interview Question
htaccess Interview Question
JavaScript Interview Question
HTML Interview Question
Python Interview Question
Django Interview Question

Từ khóa » Html Onclick Do Nothing