【发布时间】:2011-12-23 06:04:24
【问题描述】:
我的 jQuery 函数是这样的
$('input[type="text"]').focus(function() {
$("label").css("border-bottom-color", "red");
});
$('input[type="text"]').blur(function() {
$("label").css("border-bottom-color", "#e6e6e6");
});
1) 我的表单中有一堆文本输入。我想要做的是更改焦点文本框标签的底部边框颜色(每个文本框都有一个标签。我只想更改焦点文本框标签的边框颜色)。但是我的函数一次改变了所有标签的边框颜色。如何解决这个问题?
2) 我有 2 个表格。带有 id 的 form1 和 form2。我想对第二种形式做同样的事情,但颜色会是另一种。如何修改这个函数?
我的表格是这样的
<form id="form1">
...
<label for="fname">First Name</label>
<input name="fname" placeholder="please enter your first name" type="text" />
...
</form>
<form id="form2">
...
<label for="job">Your Job</label>
...
<input name="job" placeholder="please enter your job" type="text" />
</form>
【问题讨论】:
标签: javascript jquery css colors border