Javascript 从下拉菜单选项显示“标题”标签

Javascript 从下拉菜单选项显示“标题”标签,javascript,jquery,html,css,Javascript,Jquery,Html,Css,我正在使用上面的代码。是否可以从下拉菜单中显示所选选项的标题标签?现在,当我将鼠标悬停在下拉菜单中的某个选项上时,标题会弹出,但我还希望在为该特定货币做出选择后,在单独的文本区域中显示该标题。我该怎么做 只需从所选选项中选择属性标题,并用它填充文本区域。假设您的文本区域是一个id为text area的div。您可以这样做: <form name="currency select" title="Currency Selector"> <select name="curr

我正在使用上面的代码。是否可以从下拉菜单中显示所选选项的标题标签?现在,当我将鼠标悬停在下拉菜单中的某个选项上时,标题会弹出,但我还希望在为该特定货币做出选择后,在单独的文本区域中显示该标题。我该怎么做

只需从所选选项中选择属性标题,并用它填充文本区域。假设您的文本区域是一个id为text area的div。您可以这样做:

<form name="currency select" title="Currency Selector">
    <select name="currency" style="background: #2D3A47; no-repeat left center; cursor: pointer; width: 49px; height: 29px; onchange="window.document.location.href=this.options[this.selectedIndex].value;" value="GO">
        <option value="" disabled="disabled" selected="selected" none="">$ € £</option> 
        <option value="/session/currency/usd/" title="US Dollar">USD</option>
        <option value="/session/currency/eur/" title="EURO">EUR</option>

就这样。

悬停和选择;是,在hover和selectionBind上,选项元素的两个事件悬停,选择元素的两个事件更改;谢谢,但是我该怎么做呢?谢谢,约吉塔,但是我不能让它工作。是$'divtext-area'.text$'.select'.attr'title';我应该使用的确切代码是什么?我已经创建了一个id为text area的div。@您可以创建一个div,也可以使用标记textarea,通过获取所选元素的attr title来使用相同的方法设置文本属性。谢谢,Vijay。因为我无法让它工作,所以我制作了一个JSFIDLE。请看一下,好吗?代码没有运行,因为JSFIDLE是一个java脚本编辑器。因此,包括jquery插件脚本,我编辑了上面的代码片段,包括Hi Vijay,我发现了哪里出了问题。请参见上面的答案,其中我添加了一些代码:onchange=window.document.location.href=this.options[this.selectedIndex].value;你知道一个解决方案吗??
$('div#text-area').text($('.select').attr('title'));
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
</head>
<body>
<form name="currency select" title="Currency Selector">
    <select name="currency" id="currencyList" value="GO">
        <option value="" disabled="disabled" selected="selected" none="">$ € £</option> 
        <option value="/session/currency/usd/" title="US Dollar">USD</option>
        <option value="/session/currency/eur/" title="EURO">EUR</option>
    </select>

    <textarea id="showTitle"></textarea>

</form>
</body>
<script>
$(document).ready(function()
{
    $(document).on('change','#currencyList',function()
    {
       var result = $("option:selected",this).attr('title');
       $("#showTitle").text(result);
    });
});
</script>