Without having a href
, the click will reload the current page, so you need something like this:
<a href="#" onclick="f1()">jhhghj</a>
Or prevent the scroll like this:
<a href="#" onclick="f1(); return false;">jhhghj</a>
Or return false
in your f1
function and:
<a href="#" onclick="return f1();">jhhghj</a>
….or, the unobtrusive way:
<a href="#" id="abc">jhg</a> <a href="#" id="myLink">jhhghj</a> <script type="text/javascript"> document.getElementById("myLink").onclick = function() { document.getElementById("abc").href="xyz.php"; return false; }; </script>
Related Posts:
- window.location.href and window.open () methods in JavaScript
- Open URL in same window and in same tab
- JavaScript function in href vs. onclick
- anchor jumping by using javascript
- Google reCAPTCHA V3.0 not working. “ERROR for site owner: Invalid key type”
- Javascript split regex question
- Find object by id in an array of JavaScript objects
- Cannot set property InnerHTML of null [duplicate]
- How can I submit a form using JavaScript?
- How to set NODE_ENV to production/development in OS X
- How fix ‘Failed to load resource: the server responded with a status of 403’?
- How do I empty an array in JavaScript?
- JavaScript TypeError: Cannot read property ‘style’ of null
- JavaScript string newline character?
- How to create a GUID / UUID
- How does “/\s/g” replace spaces with other characters?
- What is the correct way to check for string equality in JavaScript?
- Check if element exists in jQuery
- Checking a Url in Jquery/Javascript
- Usage of the backtick character (`) in JavaScript
- Why is using “for…in” for array iteration a bad idea?
- Parsing a string to a date in JavaScript
- Number converted in 1e+30
- Static variables in JavaScript
- ReferenceError : window is not defined at object.
Node.js - Node.js Port 3000 already in use but it actually isn’t?
- Uncaught TypeError: $.post is not a function
- XML Parsing Error: no root element found Location in Console FF
- TypeError: app.use() requires middleware functions
- Possible to extend types in Typescript?
- JavaScript enumerator?
- How to format numbers as currency strings
- Convert UTC date time to local date time
- How can I convert a string to boolean in JavaScript?
- “.addEventListener is not a function” why does this error occur?
- Obtain form input fields using jQuery?
- Npm install cannot find module ‘semver’
- How to download a file with Node.js (without using third-party libraries)?
- Getting current date and time in JavaScript
- What is ViewChild in Angular2?
- Permutations in JavaScript?
- How do I remove documents using Node.js Mongoose?
- jQuery make global variable
- Mixed Content Page: requested an insecure stylesheet error
- How to do integer division in javascript (Getting division answer in int not float)?
- javascript unexpected identifier
- How to send email by using javascript or jquery
- Access to Image from origin ‘null’ has been blocked by CORS policy
- Open URL in new window with JavaScript
- Read XML file using javascript
- Load Image from javascript
- Most efficient method to groupby on an array of objects
- Don’t make functions within a loop [duplicate]
- Difference between ?:, ?! and ?=
- JavaScript post request like a form submit
- How to change the text of a label?
- How to check ‘undefined’ value in jQuery
- Detecting arrow key presses in JavaScript
- Data column(s) for axis #0 cannot be of type string in google chart dashboard [duplicate]
- JavaScript – Count Number of Visitor for Website
- Jquery Value match Regex
- replace space with dash JavaScript
- Using “×” word in html changes to ×
- How do I store an array in localStorage?
- How to check if the URL contains a given string?
- How to enable CORS in AngularJs
- bootstrap buttons onclick events
- How do I install Angular 2 using NPM?
- Detecting a mobile browser
- jQuery .animate() not working
- how to add inside a text box?
- is it posible to add anime.js in WordPress
- Is it possible to enqueue the Youtube API script or does it have to be inline?
- What type of template are WP media-modal’s templates?
- Correctly handling WordPress core data retrieval in Gutenberg
- is_front_page() not working
- Gutenberg RichText
- How to use wp.hooks.addAction() in React JS/Gutenberg?
- Sending custom data with Media Frame Model
- Unwanted line break before
- Multiple Conditional Controllers
- Adding javascript trigger to user role selection on the user-edit page
- Weird links found in wordpress footer
- How to add if lt IE9 conditional scripts to functions.php
- Looping over wordpress meta to create “ ‘s?
- How to include a JSON file on my page?
- Adding inline JavaScript after wp_enqueue_scripts
- Install GTM in pure javascript through functions.php
- Update media library attachments
- JavaScript Libraries in WordPress
- how to let users upload their custom cover image
- how to use nimble-API and Display data?
- Can’t get rid of JQMIGRATE: Migrate is installed, version 3.3.2. Manually updated all the libralies and site. 5.8.2
- Create new product with woocommerce REST API with javascript (clientside)?
- Combining results from WP-API using AngularJS
- Get current day using javascript [closed]
- dropdown does not work [closed]
- Anyway to disable the auto excerpt creation?
- Why is this script not working?
- Astra Mobile Cart Drawer is blank on home page