Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Aug 17 09:32
    User @bjorno43 unbanned @linkin-park
  • Jun 20 21:19
    @bjorno43 banned @shenerd140
  • Apr 25 17:13
    @mstellaluna banned @cmal
  • Jan 08 22:05
    @mstellaluna banned @dertiuss323
  • Nov 07 2018 04:42
    User @texas2010 unbanned @ows-ali
  • Nov 02 2018 16:25
    @texas2010 banned @ows-ali
  • Oct 12 2018 05:50
    @bjorno43 banned @NACH74
  • Oct 05 2018 23:02
    @mstellaluna banned @JomoPipi
  • Sep 16 2018 12:21
    @bjorno43 banned @yash-kedia
  • Sep 16 2018 12:16
    @bjorno43 banned @vnikifirov
  • Sep 05 2018 08:12
    User @bjorno43 unbanned @androuino
  • Sep 05 2018 07:38
    @bjorno43 banned @androuino
  • Aug 23 2018 16:57
    User @bjorno43 unbanned @rahuldkjain
  • Aug 23 2018 16:23
    @bjorno43 banned @rahuldkjain
  • Jul 29 2018 14:13
    User @bjorno43 unbanned @jkyereh
  • Jul 29 2018 01:00
    @bjorno43 banned @jkyereh
  • Jul 10 2018 22:09
    @bjorno43 banned @manafn
  • Jul 06 2018 15:20
    @texas2010 banned @imlegend19
  • Jul 03 2018 12:28
    @bjorno43 banned @vbvmatta
  • Jun 29 2018 13:54
    @bjorno43 banned @OGTechnoBoy
a27-suryansh
@a27-suryansh
@sjames1958gm it is already under that
Stephen James
@sjames1958gm
@a27-suryansh Oops - never mind - it is there already - forget all I said
a27-suryansh
@a27-suryansh
@sjames1958gm i have heard that we cannot target elements with dynamically added classes is that right?
Stephen James
@sjames1958gm
@a27-suryansh I doubt that is the case, but there might be some timing issue.
Why are you targetting an element with #clk_london_map2_changed when you can already target it with ".clk_london_map2"
Unless this is some sort of experiment?
a27-suryansh
@a27-suryansh
no actually there are images of map in the web page and when user clicks on map2 then both maps should interchange that's why @sjames1958gm
@sjames1958gm there are only 2 maps
Stephen James
@sjames1958gm
@a27-suryansh Dang I should look closer did not see the 1 and the 2
a27-suryansh
@a27-suryansh
It interchanges one time but fails to interchange second time coz you know second click function is not working @sjames1958gm
Stephen James
@sjames1958gm
@a27-suryansh You cannot target a element when the id is added later. After you add the id to the element, then you can target it
a27-suryansh
@a27-suryansh
@sjames1958gm as you can see in my code i am first changing the class only then i am targeting it on the next click event
```
$(".clk_london_map2").on("click", function() {
this changes the id @sjames1958gm
i cant figure out what i am doing wrong @sjames1958gm
Stephen James
@sjames1958gm
@a27-suryansh
$("#clk_london_map2_changed").on("click", function() {
This code runs on page ready, before you have ever clicked and run the code above it.
You cannot reference an ID that is assigned later
a27-suryansh
@a27-suryansh
ok got it @sjames1958gm
Stephen James
@sjames1958gm
@a27-suryansh :+1:
a27-suryansh
@a27-suryansh
@sjames1958gm i think this code should be placed under the first click event right?
Damn @sjames1958gm
@sjames1958gm Works like a charm!
Stephen James
@sjames1958gm
:+1:
Timing is everything :)
a27-suryansh
@a27-suryansh
@sjames1958gm may god bless you i was stuck at it for hours
Markus Kiili
@Masd925
@a27-suryansh Don't insult him. HE is the one who blesses others here.
a27-suryansh
@a27-suryansh
@Masd925 he just blessed me that's why i asking god to bless him
Markus Kiili
@Masd925
@a27-suryansh He is the brownie god, so that is why it insults him.
a27-suryansh
@a27-suryansh
you mean to say even god can't bless him now @Masd925
Markus Kiili
@Masd925
@a27-suryansh It depends on how many brownies that god in questions has.
a27-suryansh
@a27-suryansh
infinite @Masd925
Markus Kiili
@Masd925
@a27-suryansh That is hard to swallow. Are we assuming that string theory holds?
Stephen James
@sjames1958gm
@a27-suryansh You're welcome.
a27-suryansh
@a27-suryansh
@Masd925 i am not aware of that theory but seems interesting
@sjames1958gm i have made a codepen for that issue and putting the click code under that has created new issue - https://codepen.io/anon/pen/KoRBWp please have a look at it
@sjames1958gm interchaning works for 2-3 clicks then it stops
a27-suryansh
@a27-suryansh
@sjames1958gm the second click function under the click function is the reason it is not changing the image after 2-3 clicks but if i move the second click function out of the first click function then it doesn't works coz as you said it is unable to reference the element but now what is the solution?
Stephen James
@sjames1958gm
Rather than move around click handlers, let your data determine what happens with a single handler.
  var pics = ["http://www.youloveit.ru/uploads/posts/2013-11/1385565011_youloveit_ru_sobaka_bu02.jpg",
             "https://www.what-dog.net/Images/faces2/scroll001.jpg"];
  var pic1ndx = 0;
  var pic2ndx = 1;
  $(".clk_london_map2").on("click", function() {
    $(".clk_london_map1").attr(
      "src",
      pics[pic1ndx]
    );
    $(".clk_london_map2").attr(
      "src",
      pics[pic2ndx]
    );
    pic1ndx = (pic1ndx + 1) % pics.length;
    pic2ndx = (pic2ndx + 1) % pics.length;
  });
a27-suryansh
@a27-suryansh
Thanks for this @sjames1958gm
CamperBot
@camperbot
a27-suryansh sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 9157 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
Stephen James
@sjames1958gm
@a27-suryansh Sure. Assigning and re-assigning click handlers can get really complex quickly
a27-suryansh
@a27-suryansh
Thanks for this tip @sjames1958gm
CamperBot
@camperbot
a27-suryansh sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
api offline
Richard Sithole
@Sliqric7053
Hi guys. I would like to ensure that my header and footer do not show on the page when a specific url (e.g. www.abc.com?code=123) is visited, the url params are dynamic so I cannot hard code the case. Whats the best way to cater for cases like I've described above?
boul35
@boul35
how do you build a tribute page with no CSS?? Do you only use bootstrap. Should i build the tribute page without css?? please
Liam Docherty
@ldocherty1
the icon which shows the navbar pages disappears and turns white, when I wanted it to be black.
coderNewby
@coderNewby
@darrenfj thanks for the pm
CamperBot
@camperbot
codernewby sends brownie points to @darrenfj :sparkles: :thumbsup: :sparkles:
:star2: 2445 | @darrenfj |http://www.freecodecamp.org/darrenfj