单击时如何更改图像链接的CSS?

发布于 2024-12-16 14:46:34 字数 434 浏览 0 评论 0原文

我有一个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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

最美不过初阳 2024-12-23 14:46:34

使用commandLink的onclick事件来执行javascript。
像这样的东西

<p:commandLink onclick="changeCSSInJavascript()" ...> 
.... 
</p:commandLink>

Use onclick event of the commandLink to execute javascript.
Something like

<p:commandLink onclick="changeCSSInJavascript()" ...> 
.... 
</p:commandLink>
木有鱼丸 2024-12-23 14:46:34

您可以向 primefaces GraphicImage 添加样式属性,并从 bean 为其赋予字符串值。单击链接后,您可以使用以下内容更新该字符串值:opacity:0.4

<p:commandLink title="Forward" update="growl"
                        actionListener="#{roombaBean.forward}">
  <p:graphicImage value="images/but_forward.png" style="#{myBean.myStringStyleValue}" />
</p:commandLink>

对于 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:

<p:commandLink title="Forward" update="growl"
                        actionListener="#{roombaBean.forward}">
  <p:graphicImage value="images/but_forward.png" style="#{myBean.myStringStyleValue}" />
</p:commandLink>

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...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文