我试图隐藏并显示基于枚举的div。我知道这应该很简单,但我的JavaScript(和jQuery)非常生疏。
我的选择表格是:
weekInterval
Where我还有一堆div声明为:
monthInterval
alert(recurrency);
if (recurrency.value == 'DAILY') {
$('weekInterval').hide();
document.getElementById('weekInterval').style.display = 'block';
document.getElementById('monthInterval').style.display = 'block';
}
if (recurrency.value == 'WEEKLY') {
document.getElementById('dayInterval').style.display = 'block';
document.getElementById('monthInterval').style.display = 'block';
}
if (recurrency.value == 'MONTHLY') {
document.getElementById('dayInterval').style.display = 'block';
document.getElementById('weekInterval').style.display = 'block';
}
});
});
和Object HTMLCollection
相同。
我的JavaScript代码是:
$().ready(function () {
$('#recurrency').on('change', function () {
def multiplication_table(n):
import numpy as np
base = list(range(1, n+1))
array_shell = np.zeros(shape=(n,n), dtype=int)
array_shell[0] = base
for row in range(1,len(base)):
array_shell[row][0] = base[row]
for row in range(1, len(base)):
for idx in range(1, len(base)):
array_shell[row][idx] = base[idx]*array_shell[row][0]
return (array_shell)
my_int = 8
print(multiplication_table(my_int))
JavaScript代码的警报部分始终返回int values = 4375;
String mValue = String.valuOf(values);
Char mChar = mValue.chatAt(int index);
int selectedValue = Character.getNumericValue(mChar);
。我确信这很简单,但我看不出这里的出路。
答案 0 :(得分:0)
您需要拥有select
元素的更改事件处理程序。然后在change事件处理程序中,您可以获取select的值,然后使用.toggle()
在您的情况下,recurrency
引用div
元素(因为这是div的ID),这就是您收到类似警告消息的原因。
$(function() {
$('#recurrency select').on('change', function() {
var value = this.value;
$('#dayInterval').toggle(value == 'DAILY');
$('#weekInterval').toggle(value == 'WEEKLY');
$('#monthInterval').toggle(value == 'MONTHLY');
}).change();
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="recurrency">
<select path="recurrency">
<option value="-" label="--Please Select" />
<option value="DAILY">DAILY</option>
<option value="WEEKLY">WEEKLY</option>
<option value="MONTHLY">MONTHLY</option>
</select>
</div>
<div id="dayInterval">DAILY</div>
<div id="weekInterval">WEEKLY</div>
<div id="monthInterval">MONTHLY</div>
&#13;