-2

I have 10 anchors, and i give the id #first-project to the first anchor and when its clicked i want that the html element with an id #prev-project be hide. With my code it works but the id #prev-project stays hided all the time, only if i click on for the first time on the second anchor it's ok. How can I rewrite this code?

<script type="text/javascript">
    $("#first-project").click(function () {
        $("#prev-project").css("display", "none");
    });
</script>
Smern
  • 18,746
  • 21
  • 72
  • 90
MaTa
  • 1
  • 2
  • Why wouldn't it stay hidden, when are you showing it again ? – adeneo Apr 11 '15 at 12:20
  • Do you want to show it if you click again? Use `toggle()` if so. – Shaunak D Apr 11 '15 at 12:20
  • i want that its always hided when #first-project is active. – MaTa Apr 11 '15 at 12:24
  • as the @Shaunak D said, if you want to hide it and then , show it, you should use toggle. $("#prev-project").toggle(); – Reza-S4 Apr 11 '15 at 12:30
  • so you want to hide ` #prev-project ` when you click on ` #first-project ` , if i click any other anchor than you want to show that ` #prev-project ` right? – Jignesh Khokhariya Apr 11 '15 at 12:34
  • Ty guys but maybe i asked bad question. I cant solve that problem. FFS. i will kill myself :) – MaTa Apr 11 '15 at 12:35
  • can you please show me your all anchors? with design? – Jignesh Khokhariya Apr 11 '15 at 12:36
  • you can visit page at ( test.kroatika.com ).When you go on projects and if you open first house u will see navigation left close and right arrow. If you click on the left (previous arrow) u will get blank page and that what i am trying to not happening. Then this is one idea to hide that arrow when this link is active. – MaTa Apr 11 '15 at 12:37
  • its complicated and i can't solve that. – MaTa Apr 11 '15 at 12:37
  • ok.. i am trying to help you. let me see what i can do for you... :) – Jignesh Khokhariya Apr 11 '15 at 12:38
  • if you want to help here is my mail malapic24gmail.com. Contact me and i will give you the code and everything. – MaTa Apr 11 '15 at 12:39
  • i can't see '#first-project' in your given page. where can i find it? – Jignesh Khokhariya Apr 11 '15 at 12:43
  • this is an older version. #first-project should be – MaTa Apr 11 '15 at 12:46
  • in a first article in portfolio....family house 1 – MaTa Apr 11 '15 at 12:46
  • 1
    Your question is seeking debuging help so it has no value in for stackoverflow community at all. However, this is your problem - when you are on the first item and you click on previous button there isn't previous portfolio item to show. The solution could be to show last item (make cycle). You have this problem when you click on the next button and you are on the last portofolio item. Here is a sample code that can solve the problem: [link to pastebin](http://pastebin.com/ZStDxY3v) – Viktor Bahtev Apr 11 '15 at 12:59
  • TY TY TY. A thousand times thank you!!! How can i repay you for that? – MaTa Apr 11 '15 at 13:11

1 Answers1

0

Give a look at the second answer here: jQuery event to trigger action when a div is made visible

It's about triggering an event isVisible based on the show of an element (in your case "#first-project". You can do the same with the hide action producing an event like "notVisible".

Depending on the event triggered (isVisible or notVisible) you will bind two distinct functions where you can do whatever you want as a consequence of your #first-project element showed or not.

Community
  • 1
  • 1
  • Can you take a look at jsFiddle ( https://jsfiddle.net/duxzzzz/q9otjs80/ ) and see if this is possible to do in my code. Because i don't know hot to code that properly. – MaTa Apr 11 '15 at 13:00
  • @MaTa : The road you were trying is not the good one to solve your problem, Viktor has posted the proper one to your problem. – Artemide Innominato Apr 11 '15 at 13:20
  • Yeah i see. Anyway i want to ty all of you for trying to help me! TY – MaTa Apr 11 '15 at 13:28