如果我选择攀登,我想隐藏攀爬和爬升 这是我的代码和下面的javascript
HTML:
<span id="climt" class="themesegclass" style="display: none;">
<span id="outputimgsrc"></span>
</span>
<span id="climbn" class="themesegclass" style="display: none;">
<span id="outputimgsrc"></span>
</span>
<Select id="themeselector">
<option value="climb">Classic - Image Bottom</option>
<option value="climt">Classic - Image Top</option>
<option value="climbn">Classic - Image Below Name</option>
</Select>
Java脚本:
$(function() {
var inputimgsrc = document.getElementById("inputimgsrc").value;
document.getElementById("outputimgsrc").innerHTML = "<img src=" + inputimgsrc + " style='width: 100px; height: 100px;'>";
$('#themeselector').change(function () {
$('.themesegclass').hide();
$('#' + $(this).val()).show();
});
});
答案 0 :(得分:-1)
我无法添加注释,但是它可以像您使用相同的id(outputimgsrc)两个跨度一样简单吗?
<span id="climt" class="themesegclass" style="display: none;"><span id="outputimgsrc"></span></span> <span id="climbn" class="themesegclass" style="display: none;"><span id="outputimgsrc"></span></span>