admin管理员组文章数量:1414852
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
1 Answer
Reset to default 1You 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.
本文标签: imagesTrying to create a mouseover effect in html using Gutenberg editor
版权声明:本文标题:images - Trying to create a mouseover effect in html using Gutenberg editor 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745203917a2647538.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论