我对JavaScript和jQuery非常新颖。我试图实现一个下拉选择框,其中,当某些项目被选中时,输入文本框被禁用。我能够从不同的StackOverflow问题,黑客一起一些jQuery来实现:将jQuery代码转换为Javascript
<select name="Severity-of-your-symptoms" id="Severity-of-your-symptoms" class="cformselect" >
<option value="full01_severity_notselected" selected="selected">Please select...</option>
<option value="full01_severity_other">Mild</option>
<option value="full01_severity_other">Moderate</option>
<option value="Severe">Severe</option>
<option value="full01_severity_other">Other</option>
</select>
<br />
<input type="text" id="li-10-14" />
<input type="text" name="firstname" title="First Name" style="color:#888;"
value="First Name" onfocus="inputFocus(this)" onblur="inputBlur(this)" id='color'/>
<script type='text/javascript' src='http://code.jquery.com/jquery-1.4.2.js'></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.0/jquery-ui.js"></script>
<script type="text/javascript">
$('#Severity-of-your-symptoms').change(function() {
$("#li-10-14")[$(this).val() == "full01_severity_other" ? 'show' : 'hide']("fast");
}).change();
$('#Severity-of-your-symptoms').change(function() {
$("#li-10-14")[$(this).val() == "full01_severity_other" ? $('#color').attr("disabled", true)
: $('#color').attr("disabled", false)]
}).change();
</script>
我真的很想在Javascript来实现这一点,但只能够得到它使用jQuery,任何人都可以帮助我转换成纯JavaScript这?
为什么?你有没有在jQuery中这样做的紧迫原因? – 2012-03-01 23:57:16
jQuery _is_ Javascript。你尝试了什么?你为什么不喜欢jQuery? – SLaks 2012-03-01 23:57:27
感谢您的意见。我明白,jQuery是一个Javascript库,它是_is_ Javascript。这主要是一个学习练习,我想了解如何在没有jQuery库的情况下编写上面的代码。 – user1152142 2012-03-02 00:12:10