jsf 中每个 SelectOneMenu 项的工具提示 [英] ToolTip for each SelectOneMenu Items in jsf

查看:28
本文介绍了jsf 中每个 SelectOneMenu 项的工具提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的要求是为每个选项提供一个 tooltipSelectOneMenu 因为选项标签太大了不可能提供这么大的 SelectOneMenu .所以标签正在切割.这就是为什么我需要工具提示来显示鼠标悬停在 SelectOneMenu 中选项的整个值.

My requirement is to provide a tooltip for every option in the SelectOneMenu because label of option is so large that it's not possible to provide such a large size SelectOneMenu .So the label is cutting. Thats why i need tooltip to show the whole value on mouse over of the options in the SelectOneMenu .

任何想法将不胜感激.

推荐答案

您可以使用 javascript.假设您的 selectOneMenu 如下所示.

You can use javascript. Assume your selectOneMenu as below.

<h:form id="form1">
    <h:selectOneMenu id="combo1">
        <f:selectItem itemLabel="First Label"/>
        <f:selectItem itemLabel="Second Label"/>
        <f:selectItem itemLabel="Third Label"/>
    </h:selectOneMenu>
</h:form>

在页面顶部添加此脚本.

Add this script at the top of your page.

<script>
    window.onload = function() {
         var options = document.getElementById("form1:combo1").options;
         for(var i = 0; i &lt; options.length; i++) {
             options[i].title = options[i].innerHTML;
         }
    }
</script>

这篇关于jsf 中每个 SelectOneMenu 项的工具提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆