Html 我想在单击下拉列表时清除一个文本框
这是我的代码,我的下拉列表工作Html 我想在单击下拉列表时清除一个文本框,html,onfocus,Html,Onfocus,这是我的代码,我的下拉列表工作 <select id="PublisherID" name="$publisher" onfocus="if(this.id=='PublisherID') if(this.value='value') 这是您实现它的方法 Jquery: //For example on change of list $('#list').change(function(){ alert('list changed : clear text'); //Se
<select id="PublisherID" name="$publisher" onfocus="if(this.id=='PublisherID') if(this.value='value')
这是您实现它的方法
Jquery:
//For example on change of list
$('#list').change(function(){
alert('list changed : clear text');
//Set what value you want for text field');
$('#text').val('Search...');
});
HTML:
选项
一个
两个
三
四
这里有一个演示:
自由人
内存
函数cleartextbox(){
document.getElementById(“标记”).value=“”;
}
做记号
我假设这是您正在使用的JavaScript?请将该信息添加到问题中。
//For example on change of list
$('#list').change(function(){
alert('list changed : clear text');
//Set what value you want for text field');
$('#text').val('Search...');
});
<select id='list'>
<option>Option</option>
<option>One</option>
<option>Two</option>
<option>Three</option>
<option>Four</option>
</select>
<input type="text" id="text" value="Search..."/>
<select onchange="cleartextbox()">
<option value="libero">libero</option>
<option value="Ram">Ram</option>
</select>
<script type="text/javascript">
function cleartextbox() {
document.getElementById("mark").value = "";
}
</script>
<label>
<span>Mark</span>
<input type="text" name="mark" id="mark" >
</label>