我需要基本的if脚本帮助 https://jsfiddle.net/TeoMorabito/92mtqf54/2/#&togetherjs=3z41zCsyOi
我确定这很明显哈哈
var selectedVal = document.getElementsByName('select-yui_3_17_2_1_1540352978001_90484-field').value;
if(selectedVal == 'NO')
{var element = document.getElementById('textarea-yui_3_17_2_1_1540167138612_32440');
element.style.visibility = 'hidden';}
答案 0 :(得分:1)
首先,您必须调用dropdown的onChange函数,然后必须使用ID获取Dropdown的值。请参阅下面的工作代码。
$(function() {
$('#yui_3_17_2_1_1540357839233_566').change(function(){
var selectedVal = document.getElementById('yui_3_17_2_1_1540357839233_566').value;
var element = document.getElementById('textarea-yui_3_17_2_1_1540167138612_32440');
if(selectedVal == 'NO')
{
element.style.visibility = 'hidden';
}else{
element.style.visibility = 'visible';
}
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="select-yui_3_17_2_1_1540352978001_90484" class="form-item field select">
<label class="title" for="select-yui_3_17_2_1_1540352978001_90484-field">Found a Turtle track or nest ?</label>
<div class="description">if something of interest was found, please proceed to the next section of the data sheet
If no, then scroll to the bottom and submit the data sheet.</div>
<select name="select-yui_3_17_2_1_1540352978001_90484-field" id="yui_3_17_2_1_1540357839233_566">
<option value="YES">YES</option>
<option value="NO">NO</option>
</select>
</div>
<div id="textarea-yui_3_17_2_1_1540167138612_32440" class="form-item field textarea">
<label class="title" for="textarea-yui_3_17_2_1_1540167138612_32440-field">Location Description</label>
<textarea class="field-element " id="textarea-yui_3_17_2_1_1540167138612_32440-field"></textarea>
</div>