单击时如何更改图像链接的CSS?
我有一个commandLink,里面有一个graphicImage,我想更改一些属性 链接以显示它已被单击。我找不到用于此目的的内置属性。 也许需要一些 javascript 或 css 代码。因为我不太擅长这些,如果有人可以指导我,我会很高兴。谢谢
这是链接的代码。
<p:commandLink title="Forward" update="growl"
actionListener="#{roombaBean.forward}">
<p:graphicImage value="images/but_forward.png" />
</p:commandLink>
i have a commandLink that has a graphicImage inside and i want to change some property
of the link to show that it is clicked.I could find no built-in property for that purpose.
Maybe some javascript or css code is required.Since i am not so good at those,i'd be glad if someone could guide me a way.Thanks
Here is the code of the link.
<p:commandLink title="Forward" update="growl"
actionListener="#{roombaBean.forward}">
<p:graphicImage value="images/but_forward.png" />
</p:commandLink>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用commandLink的onclick事件来执行javascript。
像这样的东西
Use onclick event of the commandLink to execute javascript.
Something like
您可以向 primefaces GraphicImage 添加样式属性,并从 bean 为其赋予字符串值。单击链接后,您可以使用以下内容更新该字符串值:
opacity:0.4
:对于 IE8 及更早版本,请使用
filter:alpha(opacity=40);
无论如何,我不这样做真的明白你为什么想要这样的东西吗?您不离开该页面吗?为什么图像被点击真的很重要?请您提供更多信息,我们可以看看是否有更好的解决方案...
You could add a style attribute to primefaces graphicImage and give it a string value from a bean. After the link it's clicked you could update that string value with:
opacity:0.4
:For IE8 and earlier use
filter:alpha(opacity=40);
Anyway I don't really understand why do you want something like this? Don't you navigate away from the page? Why is it really matter that the image was clicked? Please, if you could give some more info, we could see if there is a better solution...