If you want to redirect a webpage to some other using jQuery, then you can make use of the following,
var redirectURL = 'The url where you want the page to be redirected';
$(location).attr('href',redirectURL);
Let's see an example, where we have a Page A with a button, when clicked we redirect the page to Page B,
<html>
<head>
<title>jQuery Redirect</title>
</head>
<body>
<input id="myButton" type="button" value="Redirect to Page B">
<script>
$('#myButton').click(function() {
var redirectURL = 'pageB.html';
$(location).attr('href', redirectURL);
});
</script>
</body>
</html>
More Posts related to jQuery,
- jQuery: Check if an element exists or not
- [jQuery] Uncaught ReferenceError: $ is not defined at index.html:5
- Make div element draggable using jQuery
- jQuery : Move to top of the page
- Dynamically Obtaining Browser Screen Width and Height with jQuery [Updated 2023]
- How to check if an element is hidden using jQuery code?
- Redirect page using jQuery
- Disable jQuery button after being click
More Posts:
- How to increase macOS Terminal text font size (Big Sur) - MacOS
- PowerShell Traditional For Loop Example - Powershell
- Make Notepad++ the default App for .txt file extensions - NotepadPlusPlus
- How to Check PowerShell Version? [Windows/Mac/Linux] - Powershell
- 18: Get Sub List By Slicing a Python List - 1000+ Python Programs - Python-Programs
- How to Sort a LinkedList in Java - Java
- How to know the Serial Number of MacBook on macOS Ventura 13.0 - MacOS
- SharePoint 2016 error - Could not find file ManageUserProfileServiceApplicationTenantSimplified.xml - SharePoint