2

I was trying to do this with pure CSS by using the :focus and tabindex method for interacting with <div>'s but when I tried to add a video through HTML it broke it all so I have had to resort to jQuery.

I'm new to JavaScript but what I'm trying to do is make it so when you click on the #about_me.tab:before element it moves the #about_me.tab to 0vh and changes its z-index to 5 and then alters the box-shadow but this isn't working can anyone see a problem or is it the HTML or CSS

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
  $("#about_me.tab:before").click(function(){
    $("#about_me.tab").css({"transition":"top 1s, z-index 0s","top":"0vh","z-index":"5","box-shadow":"0 0 8vw black"});
  });
});
</script>

Indy

3
  • 1
    What "isn't working"? Is it firing the click event handler? If not, your first selector is wrong, if it is firing - your second selector is wrong. Commented Nov 7, 2014 at 11:10
  • 7
    You can't select pseudo-element via jQuery/JS, because they are not in DOM. Commented Nov 7, 2014 at 11:12
  • have you considered reacting somehow on answers? :) Commented Nov 7, 2014 at 12:34

2 Answers 2

1

You should use jQuery selector instead of using pseudo-elements:

 $("#about_me.tab").prev().click(function(){
    $("#about_me.tab").css({"transition":"top 1s, z-index 0s","top":"0vh","z-index":"5","box-shadow":"0 0 8vw black"});
 });

or

 $("#about_me.tab").click(function(){
    $("#about_me.tab").prev().css({"transition":"top 1s, z-index 0s","top":"0vh","z-index":"5","box-shadow":"0 0 8vw black"});
 });
Sign up to request clarification or add additional context in comments.

Comments

0

jQuery

$("#about_me.tab").addClass('shadow');

CSS

.shadow{
//Your style

}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.