images - Trying to create a mouseover effect in html using Gutenberg editor

I am trying to create a mouseover effect in html on a content block in the Wordpress code editor. I want an icon to chan

I am trying to create a mouseover effect in html on a content block in the Wordpress code editor. I want an icon to change color on mouseover and change back on mouseout so I'm referencing two different colored icon pictures. I'm also not sure what best practices are for spacing/indent; sorry if this is messy or hard to read.

Here is the code I'm using to try to accomplish this:

HTML
<!-- wp:image {"id":1111} -->
<figure class="wp-block-image"><img src=".png"onmouseover="this.src='//wp-content/uploads/2019/08/image2.png'"onmouseout="this.src='//wp-content/uploads/2019/08/image1.png"' alt="alttext" class="wp-image-1111"/></figure>
<!-- /wp:image -->

I am trying to create a mouseover effect in html on a content block in the Wordpress code editor. I want an icon to change color on mouseover and change back on mouseout so I'm referencing two different colored icon pictures. I'm also not sure what best practices are for spacing/indent; sorry if this is messy or hard to read.

Here is the code I'm using to try to accomplish this:

HTML
<!-- wp:image {"id":1111} -->
<figure class="wp-block-image"><img src="https://website/wp-content/uploads/2019/08/image1.png"onmouseover="this.src='https://website//wp-content/uploads/2019/08/image2.png'"onmouseout="this.src='https://website//wp-content/uploads/2019/08/image1.png"' alt="alttext" class="wp-image-1111"/></figure>
<!-- /wp:image -->
Share Improve this question asked Aug 28, 2019 at 19:44 JenTen10JenTen10 133 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

You were very close. You just had a single-quote swapped with a double-quote after the onmouseover.

<figure class="wp-block-image">
    <img src="https://website/wp-content/uploads/2019/08/image1.png" onmouseover="this.src='https://website//wp-content/uploads/2019/08/image2.png';" onmouseout="this.src='https://website/wp-content/uploads/2019/08/image1.png';" alt="alttext" class="wp-image-1111"/>
</figure>

I usually place semi-colons after the single-quotes to make it easier to tell when your quotes are balanced, whether Javascript requires it, or not.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745203918a4616491.html

相关推荐

  • images - Trying to create a mouseover effect in html using Gutenberg editor

    I am trying to create a mouseover effect in html on a content block in the Wordpress code editor. I want an icon to chan

    7小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信