Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 我想在单击下拉列表时清除一个文本框_Html_Onfocus - Fatal编程技术网

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>