这种形式存在两个问题:
HTML:
<form target="_blank" onsubmit="window.location = 'http://sub1.domain.com?tt=' + search.value; return false;">
<label><input type="radio" name="optradio" value="1"> Tracking ID</label>
<label><input type="radio" name="optradio" value="2" > OPC</label>
<div id="Track1" class="desc" style="display: none;">
<br />
<input id="search" class="TrackInput" onclick="this.placeholder=''" onblur="this.placeholder='IYIUY'" type="text" placeholder="IYIUY" type="search" name="search">
<br />
<button type="submit" value="Submit">Track</button>
</div>
<div id="Track2" class="desc" style="display: none;">
<a href="http://sub2.domain.com" target="_blank">LOGIN</a>
</div>
</form>
JS:
$(document).ready(function() {
$("input[name$='optradio']").click(function() {
var test = $(this).val();
$("div.desc").hide();
$("#Track" + test).show();
});
});
有人可能会考虑为什么这两个问题都会发生?
答案 0 :(得分:0)
您已在return false
onsubmit
event
中添加了form
onsubmit="window.location = 'http://sub1.domain.com?tt=' + search.value; return false;">
return false
会阻止其默认操作。所以最后删除return false
。其他一切看起来都不错。
<强> 强>
Updated Fiddle
强>