我在JQuery中使用以下代码,下面是提交表单
<script type="text/javascript">
$(document).ready(function() {
$("#selhead").click(function() {
$("#fcourt").show();
});
$("#selfile").click(function() {
$("#fcourt").hide();
});
});
</script>
<form method="get" action="search.php" name="abc">
<label for='search'>Search : </label>
<input name="searchterm" type="text" class="searchbox_field" size="60" />
<input class="searchbox_field" type="submit" value="Submit" />
<div style="font-size:14px; color:blue; font-weight:bold">
<input class="searchbox_field" type="radio" name="sel" value="headnote" id="selhead" checked />: Headnote</div>
<div style="font-size:14px; color:blue;; font-weight:bold">
<input class="searchbox_field" type="radio" name="sel" value="filenumber" id="selfile" />: Search by File Number</div>
现在我的问题是搜索框中的用户类型“租和驱逐”并提交表单但我想将其更改为“租借和驱逐”意味着更改“&amp;”用'和'术语
答案 0 :(得分:0)
这应该有用。
<script type="text/javascript">
$(document).ready(function() {
$("#selhead").click(function() {
$("#fcourt").show();
});
$("#selfile").click(function() {
$("#fcourt").hide();
});
$("#searchform").submit(function() {
$("#searchterm").val($("#searchterm").val().replace("&","and"));
});
});
</script>
<form method="get" action="search.php" name="abc" id="searchform">
<label for='search'>Search : </label>
<input name="searchterm" type="text" id="searchterm" class="searchbox_field" size="60" />
<input class="searchbox_field"type="submit" value="Submit" />
<div style="font-size:14px; color:blue; font-weight:bold">
<input class="searchbox_field" type="radio" name="sel" value="headnote" id="selhead" checked />: Headnote</div>
<div style="font-size:14px; color:blue;; font-weight:bold">
<input class="searchbox_field" type="radio" name="sel" value="filenumber" id="selfile" />: Search by File Number</div>
为了便于访问,我建议更改
$("#selhead").click(function() {
$("#fcourt").show();
});
及其对应$("#selhead:checked").change(function() {
$("#fcourt").show();
});
答案 1 :(得分:0)
你可以做这样的事情
if ($('.searchbox_field').text().indexOf('&') >= 0)
{
$('.searchbox_field').text().replace('&', 'and');
}