Is there a way to change the border of the CSS div when the input field gets focus (for example, when it loses focus, removes the border).
HTML:
<input type="text" name="title" id="title"></input> <div id="mainTitle">The Main Title</div>
CSS
#mainTitle { border: 1px solid #ccc; }
$(function() { //aka document.ready $("input#title").focus( function() { $("div#mainTitle").css("border","1px solid #ccc"); }); $("input#title").blur( function() { $("div#mainTitle").css("border",""); }); });
You could just use css if your users are working in a competent browser (like that, and not in IE, for the most part):
input:hover + #mainTitle, input:focus + #mainTitle, input:active + #mainTitle { border: 2px solid #ccc; }
Source: https://habr.com/ru/post/1774704/More articles:ReadPixel in Jogl - javaAdding a div dynamically to another using jQuery - jqueryjquery - an unwanted jump effect (this happens often, and I don't understand why) - jqueryCopying files with Unicode names - pythonto find Distance in latitude and longitude - asp.netCapistrano: deployment permissions issue - gitGet tweets that are not mentioned - twitterWhere can I store plasmoid user data? - kdeHow does the active application terminate when the battery runs out on the iOS device and shuts down? - iphoneJavascript global variables - javascriptAll Articles