Get the href link on click anchor in javascript
Created at 25-Aug-2021 ,
By samar
Get the href link on click anchor in javascript
In this article, we will see how to solve "Get the href link on click anchor in javascript".
You can get the href link on click of anchor tag in javascript. On click event we can get the href value of the anchor tag and redirect to that link and anything which you want to do with the href link.-
Get href link on click anchor tag in javascript/jQuery
<a id="anchorBtn" href="https://w3codegenerator.com"> w3codegenerator </a> <script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script> <script> $('#anchorBtn').on('click', function(e){ e.preventDefault(); let href = e.target.href; alert(href); }); </script>
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
Don't forget to share this article! Help us spread the word by clicking the share button below.
We appreciate your support and are committed to providing you valuable and informative content.
We are thankful for your never ending support.
Random Code Snippet Queries: Jquery
- (index):128 Uncaught TypeError: MobileNumberVal.test is not a function
- How to preview image before uploading in jQuery
- Preview image in BLOB URL format on choose file in jQuery
- How to get closest form input value in jQuery
- Ajax done fail ajaxcomplete in not a function
- Jquery.validate.min.js:4 Uncaught TypeError: Cannot read properties of undefined (reading 'mode')
- Execute function after Ajax call is complete
- How to check ajax request is completed in jQuery
- How to use and purpose of localstorage in javascript
- Uncaught TypeError: $.ajax is not a function
- Preview image in base64 format using jQuery on change input file
- How to remove Choose File button in jquery
- Append method to add text to body not working
- Uncaught TypeError: $.ajaxSetup is not a function
- How to reset form input element on click
- Enable click event on appended element using jQuery
- JQuery append html to below the target element
- JQuery find text and show as bold in html page
- How to create read more in jquery
- How to pass javascript variable to laravel route on ajax call
- Validate form using jQuery
- How to check object is empty or not in jQuery
- Mixed Content: The page at 'https://w3codegenerator.com/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint
- Add and remove input fields on click button using jQuery
- How to find closest upper element and append html to below it in jquery