HTML列表框单击事件(HTML helper类)
本文关键字:HTML helper 事件 列表 单击 | 更新日期: 2023-09-27 17:53:08
我使用的是asp.net mvc 4.0,vs2010
我有一个列表框和文本区:
<div class="editor-list-field">
@Html.ListBoxFor(model => model.TableColumn, new SelectList(Model.TableColumn), new { @class = "listofcolumn" , name="listofcolumn"})
@Html.ValidationMessageFor(model => model.TableColumn)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Content)
</div>
<div class="editor-multiline-field">
@Html.TextAreaFor(model => model.Content, new { cols=60,@rows=10, @class = "textarea" name = "textarea"})
@Html.ValidationMessageFor(model => model.Content)
</div>
我想知道,我怎么能产生一个事件像listbox_doubleclick
(只是例如:它可以像任何东西),并做我必须做的。
我必须显示选定的项目从列表框到文本区域。我想做的很简单。
我从昨天开始就在网上寻找解决办法,但没有任何方法可以完成这项工作。
编辑:我尝试了一些jQuery,但没有结果:
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js">
$(function() {
$('#listofcolumn').dblclick(function() { alert('clicked');
if ($(this).is(':selected')) {
var selectedId = $(this).val();
var selectedText = $(this).text();
alert(selectedText);
$('#textarea').val(selectedText);
}
});
});
</script>
你可以使用jQuery和dblClick
$('textarea').on('dblclick', function () {
alert('hola');
});