Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
464 views
in Technique[技术] by (71.8m points)

javascript - How to get onMouseOver to work on both elements

I'm building an image slider with arrow keys above the image. I want to hide the arrow icons upon leaving the arrow icons and entering the image. I have gotten it to work on the left arrow icon but once I hover over the right arrow it doesn't render only the left arrow allows both icons to appear. I would like for both icons to be able to display no matter which one is hovered.

 const hideArrows = (e) => {
    setIsHover(false);
  };

  const showArrows = (e) => {
    setIsHover(true);
  };

  return (
    <section className="slider">
      <FaIcons.FaArrowAltCircleLeft
        className={isHover ? "left-arrow" : "hide"}
        onClick={prevSlide}
        onMouseOver={showArrows}
      />

      <FaIcons.FaArrowAltCircleRight
        className={isHover ? "right-arrow" : "hide"}
        onClick={nextSlide}
        onMouseOver={showArrows}
      />
question from:https://stackoverflow.com/questions/65887847/how-to-get-onmouseover-to-work-on-both-elements

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

Please log in or register to reply this article.

OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...