How to change content of div on hover using JQuery/Javascript

后端 未结 6 1102
醉酒成梦
醉酒成梦 2021-01-29 16:37

I\'m trying to change the contents of a div when it\'s hovered over using JQuery. I\'ve seen answers on stack overflow, but I can\'t seem to get it working.

I\'ve tried

6条回答
  •  隐瞒了意图╮
    2021-01-29 17:11

    First of all, replace $("imgDiv") with $("#imgDiv") to get the element with id (#) imgDiv.

    Then $("tdiv") doesn't exist, you probably mean $("div") to select a

    tag in your DOM.

    And finally, $("tdiv").textContent doesn't exist. You can try $("div").html() or $("div").text() to get the

    tag content

    --

    Quick reminder : jQuery documentation on selectors

    $("div") will select the

    tags

    $(".element") will select tags with class="element"

    $("#element") will select tags with id="element"

提交回复
热议问题