Home > Web Front-end > HTML Tutorial > How to make the border color of the text box turn green when clicked_html/css_WEB-ITnose

How to make the border color of the text box turn green when clicked_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 12:02:31
Original
2165 people have browsed it



Reply to discussion (solution)

<script src=/scripts/jquery-1.8.3.min.js></script><script>$(function() {  $(":text").focus(function() {    $(this).css('border-color', '#0f0');  }).blur(function() {    $(this).css('border-color', '');  })});</script><input type=text><input type=text><input type=text><input type=text>
Copy after login

Is there any other way to write it? !

Just use a css pseudo-class
input:focus {
border-style: solid;
border-color: #339933;
}

input:focus{	border-style:solid;	border-color:#339933}
Copy after login
Copy after login
Copy after login

input:focus{	border-style:solid;	border-color:#339933}
Copy after login
Copy after login
Copy after login


How to implement it using div class? !


input:focus{	border-style:solid;	border-color:#339933}
Copy after login
Copy after login
Copy after login


How to implement it using div class? !


Using jQuery:
<style type="text/css">	.green{		border-style:solid;		border-color:#339933	}</style>$("#你的input的ID").focus(	function(){		$("#你的div的ID").addClass("green");			}).blur(	function(){		$("#你的div的ID").removeClass("green");		});
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template