4 Replies - 367 Views - Last Post: 31 December 2016 - 10:08 AM

#1 mercy_angel  Icon User is offline

  • D.I.C Regular

Reputation: 0
  • View blog
  • Posts: 330
  • Joined: 28-February 13

JS Script dont trigger, why?

Posted 31 December 2016 - 02:27 AM

Hello, i am having a bit strange problem.

I put a js tag under the title tag



<script src="my-script.js"></script>


and in that script is

 $(".nav a").on("click", function(){
       $(".nav").find(".active").removeClass("active");
       $(this).parent().addClass("active");
    });


But when try to go to differente tab, active is only first tab, and no the rest, like the script never trigger.
Where is mistake? I tried with some basic js code and its working, so I think that mistake is in putting this script in right place...

Here you can see whole code and its working, so I don't know where is problem when try to put that js in my code

Link

This post has been edited by mercy_angel: 31 December 2016 - 02:28 AM


Is This A Good Question/Topic? 0
  • +

Replies To: JS Script dont trigger, why?

#2 andrewsw  Icon User is online

  • say what now
  • member icon

Reputation: 6404
  • View blog
  • Posts: 25,881
  • Joined: 12-December 12

Re: JS Script dont trigger, why?

Posted 31 December 2016 - 02:48 AM

How do you know it isn't running, what is supposed to happen? Added: Perhaps Bootstrap has some default formatting for the active class? Still, a description of what should happen would help.

You can tell that the code is running by adding this line:

$(this).css('backgroundColor', 'red');

(This is a general first test to prove that code is running, using an obvious colour change.)
Was This Post Helpful? 0
  • +
  • -

#3 mercy_angel  Icon User is offline

  • D.I.C Regular

Reputation: 0
  • View blog
  • Posts: 330
  • Joined: 28-February 13

Re: JS Script dont trigger, why?

Posted 31 December 2016 - 05:33 AM

I tried some basic js code and its working, only dont work this.
Look two pictures I have added.
When click to link sertificates link, it should be selected, like you can see in picture. But for me, when click this link, selected is first, Connection list...You can see in link i have posted first, that it working,so script is good. I assume that place of putting is wrong. You have code in the link...I don't know where i have mistaken...

Attached image(s)

  • Attached Image
  • Attached Image

Was This Post Helpful? 0
  • +
  • -

#4 andrewsw  Icon User is online

  • say what now
  • member icon

Reputation: 6404
  • View blog
  • Posts: 25,881
  • Joined: 12-December 12

Re: JS Script dont trigger, why?

Posted 31 December 2016 - 09:33 AM

I cannot recognise the issue. At your linked resource when I click "Certificates list" it is selected; that is, greyer than the other tabs, like your first image.
Was This Post Helpful? 0
  • +
  • -

#5 mercy_angel  Icon User is offline

  • D.I.C Regular

Reputation: 0
  • View blog
  • Posts: 330
  • Joined: 28-February 13

Re: JS Script dont trigger, why?

Posted 31 December 2016 - 10:08 AM

You can see that when is certificates link page opened, link for that is darker, it is done by active class. For me, when click that page, darker is only first one, Connection list. I want that that field of <li> tag be darker. I said that that is a active class, but why js don't do work..Thats my problem...
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1