---
title: "How to open page use $(this) in JQuery?"  
description: "How to open page use $(this) in JQuery?"  
author: "marcel ethan"  
published: 2014-10-04  
updated: 2014-10-04  
canonical: https://www.mindstick.com/forum/2302/how-to-open-page-use-this-in-jquery  
category: "jquery"  
tags: ["jquery", "javascript"]  
reading_time: 1 minute  

---

# How to open page use $(this) in JQuery?

Here I'm [testing](https://www.mindstick.com/articles/1849/role-of-testing-in-software-development) to see if I can [click](https://www.mindstick.com/articles/12423/social-login-magento-2-one-click-to-register-social) on the anchor with the id '#slide-1285' and [log](https://www.mindstick.com/articles/126269/the-main-uses-of-log-cabins) it to the console. It [always says](https://answers.mindstick.com/qa/96170/my-microsoft-word-always-says-repair-file-how-do-i-fix-this-issue) 'not testing'. I'm [going to set up](https://yourviews.mindstick.com/view/85094/royal-enfield-going-to-set-up-assembly-lines-in-nepal-and-bangladesh) [conditions](https://www.mindstick.com/blog/394/javascript-if-else) for all id's so a [user](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server) is redirected to the correct page. Something like this:

```
<script>    $('#slidernavigation
> a').on('click', function(e){        e.preventDefault();        $(this).showSlide();        if($a.id == $('#slide-1285')){            window.location.href = http://webpage1;        }        else if($a.id == $('#slide-1286')){            window.location.href = "http://webpage2";        }                   else if($a.id == $('#slide-1287')){            window.location.href = "http://webpage3";        }  
    else($a.id == $('#slide-1288')){        window.location.href = "http://webpage4";    }          
    });</script>
```

## Replies

### Reply by Anonymous User

To get the id of the element that was clicked, you can do:

```
if ($(this).attr('id') === 'slide-1285') { window.location.href = "http://webpage1"; }
```


---

Original Source: https://www.mindstick.com/forum/2302/how-to-open-page-use-this-in-jquery

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
