Essentially, my setup consists of:
HTML:
<div class="div1">
<div class="as-text-box" contenteditable="true"></div>
</div>
CSS:
.div1{
position:absolute;
height:50px;
width:200px;
background:white;
border:1px solid #ccc;
}
.as-text-box{
position:absolute;
height:30px;
width:90%;
background:#ddd;
top:10px;
left:5%;
}
[contentEditable=true]:focus .div1{
border:1px solid black;
}
Specifically, I am looking to change the border color of div1
to black when as-text-box
is focused.
I have also attempted to achieve this using JQuery but have not been successful.
JQuery:
$(function(){
if ($(".as-text-box").is(":focus")) {
alert("Has Focus");
} else {
alert("Doesn't Have Focus");
}
});
Jsfiddle: https://jsfiddle.net/2xn5rj2y/
Any help and suggestions would be greatly appreciated.