[英]input value doesn't changes -Jquery
I have a table which consists from two rows: 我有一个由两行组成的表:
<table class="settings-edit-table">
<tbody>
<th scope="row"> Position</th>
<tr>
<td>
<div class="editable-select-holder editable-select-expanded">
<input type="text" name="position" id="position" value="Administrator-assistant"/>
<button type="button" class="editable-select-expander"></button>
<ul class="editable-select-options">
<li>Administrator-assistant</li>
<li>Chief Accountant</li>
<li>Chief Exeϲutive Officer</li>
<li>Chief Financial Officer</li>
</ul>
</div>
</td>
</tr>
<th scope="row">Language </th>
<td>
<div class="editable-select-holder editable-select-expanded">
<input type="text" name="language" id="preferredLanguage">
<button type="button" class="editable-select-expander"></button>
<ul class="editable-select-options">
<li id="en">English </li>
<li id="et">Estonian </li>
</ul>
</div>
</td>
</tr>
</tbody>
</table>
Here is Javascript: 这是Javascript:
$(document).on('click','.editable-select-expander', function() {
var $holder = $(this).parent();
$holder.toggleClass('editable-select-expanded');
$holder.on('click', 'li', function() {
var $t = $(this);
$holder.removeClass('editable-select-expanded');
$holder.find('input').val($t.text());
});
});
When I submit the form it says that language is not selected. 当我提交表格时,它说未选择语言。 Position selection works fine but language selection doesn't. 位置选择效果很好,但语言选择却不行。 I have no idea why. 我不知道为什么。 I you have any suggestions please provide 我有任何建议请提供
Verify your tags you need open and close(tr,th) look add quotes: 确认您需要打开和关闭(tr,th)的标签,然后添加引号:
<table class="settings-edit-table">
<tbody>
<th scope="row"> Position</th>
<tr>
<td>
<div class="editable-select-holder editable-select-expanded">
<input type="text" name="position" id="position" value="Administrator-assistant"/>
<button type="button" class="editable-select-expander"></button>
<ul class="editable-select-options">
<li>Administrator-assistant</li>
<li>Chief Accountant</li>
<li>Chief Exeϲutive Officer</li>
<li>Chief Financial Officer</li>
</ul>
</div>
</td>
</tr>
</th> <!-- add -->
<th scope="row">Language </th>
<tr> <!-- add -->
<td>
<div class="editable-select-holder editable-select-expanded">
<input type="text" name="language" id="preferredLanguage">
<button type="button" class="editable-select-expander"></button>
<ul class="editable-select-options">
<li id="en">English </li>
<li id="et">Estonian </li>
</ul>
</div>
</td>
</tr>
</th> <!-- add -->
</tbody>
</table>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.