gpt4 book ai didi

jquery - 单击输入并输入文本时更改 div 换行的 css

转载 作者:行者123 更新时间:2023-11-28 17:42:16 24 4
gpt4 key购买 nike

当输入中输入了文本时,如何更改包装输入的 DIV 的 css 属性?这是 CSS 还是 jquery?

当客户端在内部单击或在内部键入文本时,我希望包装输入的 DIV 改变背景颜色。

谢谢。

网页; http://www.givemehope.com/home.htm

<div id="home_find_wrapper">
<a class="home_find" href="#"></a>
<div class="home_search"><input name="company_name" type="text" value=""></div>
<div class="home_search_go"></div>
</div>


#home_find_wrapper {width:351px;height:100px;top:715px;left:71px;position:absolute;z-index:999;float:left;transition: opacity 0.5s ease-in-out;}
.home_search {width:250px;height:100px;float:left;background:#FFF;opacity:.5;transition: opacity 0.5s ease-in-out;}
.home_search_go {width:100px;height:100px;float:left;background:#FFF;opacity:.5;margin-left:1px;transition: opacity 0.5s ease-in-out;}
.home_find {width:100px;height:100px;float:left;background: url('img/home_find.png') no-repeat;opacity:1;position:absolute;top:0;left:248px;transition: opacity 0.5s ease-in-out;}
#home_find_wrapper:hover
.home_search, #home_find_wrapper:hover .home_search_go {cursor:pointer;background:#FFF;opacity:.7}

.home_search input {width:248px;height:75px;padding-top:10px;line-height:75px;background:transparent;float:left;text-align:center;margin:0 auto;border:0;font-size: 3.5em;font-family:'open_sansextrabold';color:#4D4D4D}

最佳答案

如何在输入上附加 keyup 并将 CSS 类添加到父 div?

HTML

<div>
<input type="text"/>
</div>

JS

$('input').on('keyup', function() {
var $this = $(this);
$this.parent().addClass('focus');

if (!$this.val().length) {
$this.parent().removeClass('focus');
}
});

fiddle :http://jsfiddle.net/9Kgss/

关于jquery - 单击输入并输入文本时更改 div 换行的 css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23876373/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com