0
我有一塊CSHTML,如下:MVC 4 - 獲取編輯字段的div的價值之前提交
<fieldset>
<legend>VisualisationConfigItem</legend>
<div class="editor-label">
@Html.LabelFor(model => model.Name)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Name)
@Html.ValidationMessageFor(model => model.Name)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.DataTable)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.DataTable)
@Html.ValidationMessageFor(model => model.DataTable)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Visualisation)
</div>
<div id="visualisationField" class="editor-field">
@Html.EditorFor(model => model.Visualisation)
@Html.ValidationMessageFor(model => model.Visualisation)
</div>
<div id="reportDiv"></div>
<p>
<input type="button" id="selectFilteringColumnsButton" onclick="selectFilteringColumns();" value="Select Filtering Columns" />
</p>
<p>
<input type="submit" value="Create" disabled="disabled" />
</p>
</fieldset>
在我的JavaScript函數selectFilteringColumns()我試圖獲取值鍵入到visualisationField div,這樣我可以在允許用戶單擊提交按鈕之前設置其他變量。
我的問題是,我無法獲得用戶使用JavaScript輸入到文本框中的文本。我已經嘗試了所有的以下內容:
var detailedDiv = document.getElementById('visualisationField');
var all = detailedDiv.all;
var className = detailedDiv.className;
var innerText = detailedDiv.innerText;
var localName = detailedDiv.localName;
var nodeName = detailedDiv.nodeName;
var nodeValue = detailedDiv.nodeValue;
var outerHTML = detailedDiv.outerHTML;
var outerText = detailedDiv.outerText;
var tagName = detailedDiv.tagName;
var TEXT_NODE = detailedDiv.TEXT_NODE;
var textContent = detailedDiv.textContent;
var title = detailedDiv.title;
我已經嘗試了所有的這些以及更多,和他們都不是能夠得到的文本內容的用戶類型的文本字段。
有誰知道如何得到這個文本?