Jquery:当点击输入/文本区/选择/复选框/添加一个css背景下一个字段的名称



很难用语言来解释,但是在这个表格上

http://jsfiddle.net/6SEtr/3/

我如何表达在jquery中,每当用户点击输入或文本区或选择或复选框(基本上所有的表单选项),我想添加一个#FF9背景下一个字段的名称。

示例:如果用户点击第一次选择,那么"Fecha"获得背景,如果点击第二次选择,* Pago:获得背景,如果点击第一次输入,那么"Localidad"获得背景,等等

它主要是推动用户去下一个字段突出显示下一个字段,希望这是有意义的

在这里

http://jsfiddle.net/6SEtr/8/

$(function(){
    $("input, select, textarea").focus(function(){
        $(this).closest("tr").next().find("td:first").css("backgroundColor", "#FF9");
    }).blur(function(){
       $(this).closest("tr").next().find("td:first").css("backgroundColor", "");
    });  
});
$(':input').focus(function(e){
    $(this).closest('tr').next().find('strong').css('background-color','#ff9');
}).blur(function(e){
    $(this).closest('tr').next().find('strong').css('background-color','');
});

看到演示

只需为每个输入或选择设置一个点击处理程序。

    $("input, select").click( function() {
        $(this).closest("tr").next().find("input, select").css("background-color","#f00")
    });
$('input, select, textarea').click(function() {
    $(this).parentsUntil('tr').parent().next().find('td:has(strong) strong').css('background', '#FF9');
}).blur(function() {
    $('strong').css('background', '');
});

最新更新