Using :focus to style outer div?

后端 未结 10 684
礼貌的吻别
礼貌的吻别 2020-12-02 18:24

When I begin writing text in the textarea, I want the outer div, with a class box, to have it\'s border turned solid instead of dashed, but somehow the :focus doesn\'t apply

10条回答
  •  有刺的猬
    2020-12-02 18:35

    Simple use JQuery.

    $(document).ready(function() {
      $("div .FormRow").focusin(function() {
        $(this).css("background-color", "#FFFFCC");
        $(this).css("border", "3px solid #555");
      });
      $("div .FormRow").focusout(function() {
        $(this).css("background-color", "#FFFFFF");
        $(this).css("border", "0px solid #555");
      });
    });
        .FormRow {
          padding: 10px;
        }
    
    
    
      
    
    
    
      
    First Name:
    Last Name:
    • Click an input field to get focus.
    • Click outside an input field to lose focus.

提交回复
热议问题