Change the div position when certain event triggers (Using pure JavaScript)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Amendachase
    New Member
    • May 2021
    • 1

    Change the div position when certain event triggers (Using pure JavaScript)

    Change the div position when certain event triggers (Using pure JavaScript) Hi everyone, I hope you are all doing well. I am looking forward to achieving a vibration effect for a div that is relatively positioned, dynamically on click event in pure javascript without any typescript injections, Is there any optimum way to achieve said milestone with pure javascript. I have some solutions which are typescript based, but I want it in pure javascript. The closest solution I have come across is this code.
    Code:
    $('.button').css('transform', 'translate3d(0px, -8px, 0px)');
    First, it’s in typescript, and secondly, it generates a one-dimensional effect as depicted in this tool, but I want the outcome to be multidimensiona l and smoother(more natural looking).
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    Not really my area of expertise so maybe not the answer you are looking for but you can access any element directly to change it's style directly through the HTML DOM e.g.

    Code:
    document.getElementById("YourDiv").style.<property> = "new style";
    More info at https://www.w3schools.com/js/js_htmldom_css.asp

    Comment

    Working...