Navigate input tab with values [duplicate]

1

First is not the same question as I did earlier , it is a supplementary question.

I currently have the following template in the JSFiddle that runs regularly, you press tab and scroll horizontal goes browsing, bringing input that received focus .

However, this does not work if input has value. If you assign a value to all input´ e tentar usar o tab ele até da focus mas o scroll 'does not return the same, getting ported "hidden."

How can I troubleshoot?

    
asked by anonymous 03.07.2015 / 14:52

1 answer

2

As the scroll navigates only in input without value, I resolved as follows:

 $('input').focus(function () {
    var val = "";
    var attr = $(this).attr('placeholder');
    if (typeof attr !== typeof undefined && attr !== false) {
       val = $(this).attr("placeholder")
    } else {
       val = $(this).val();
    }
    $(this).val('');
    $(this).attr("placeholder", val);
 });

  $('.data').blur(function () {
        $('.data').each(function () {
            var attr = $(this).attr('placeholder');
            if ($(this).val() == "") {
                if (typeof attr !== typeof undefined && attr !== false) {
                    $(this).val($(this).attr("placeholder"));
                } else {
                    $(this).val(0);
                }
            } else {
                $(this).attr('placeholder', $(this).val());
            }
        });
});

The logic is that simple. In focus I assign a null value to input and store the old value in placeholder .

I do not know if I have a value entry, if so, I assign this new value to blur .

So the placeholder will be empty every time you press input

    
03.07.2015 / 20:49