jquery怎么隐藏input框

使用jquery隐藏input框的方法:1.新建html项目,引入jquery;2.创建input输入框,设置id属性;3.添加button按钮,绑定onclick点击事件;4.通过id获取input对象,使用hide()方法隐藏input框;

具体步骤如下:

1.首先,新建一个html项目,并在项目中引入jquery;

<script type="text/javascript" src="/static/jquery-2.1.4.min.js"></script>


2.引入jquery后,在项目中创建一个input输入框,并设置id属性,用于测试;


<input type="text" value="" id="btn"/>

3.input输入框创建好后,添加一个button按钮,并绑定onclick点击事件,用于点击隐藏;

<button onClick="set()"></button>


4.最后,按钮添加好后,在点击事件中通过id获取input对象,在使用hide()方法即可隐藏input输入框;

function set(){

$("text").hide();

}


相关扩展:

1)使用show()方法显示input框

function set(){

$("text").show();

}


Both comments and pings are currently closed.

Comments are closed.

Powered by KingAbc | 粤ICP备16106647号-2 | Loading Time‌ 0.232