Home > DeveloperSection > Forums > How to open page use $(this) in JQuery?
marcel ethan
marcel ethan

Total Post:105

Posted on    October-04-2014 4:11 AM

 JQuery JavaScript  JQuery 

 1 Reply(s)
 925  View(s)
Rate this:

Here I'm testing to see if I can click on the anchor with the id '#slide-1285' and log it to the console. It always says 'not testing'. I'm going to set up conditions for all id's so a user is redirected to the correct page. Something like this:


    $('#slidernavigation > a').on('click', function(e){



        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";




Kamlakar Singh
Kamlakar Singh

Total Post:194

Posted on    October-04-2014 4:17 AM

To get the id of the element that was clicked, you can do:

if ($(this).attr('id') === 'slide-1285') { window.location.href = "http://webpage1"; }

Don't want to miss updates? Please click the below button!

Follow MindStick