Navigate tab input with values

Asked

Viewed 182 times

1

First of all it is not the same question that did previously, is a supplementary question.

I currently have the following model on Jsfiddle that works regularly, you will pressing tab and the scroll horizontal goes sailing, bringing the input who received focus.

However, this does not work if the input has value. If you assign a value to all input´ e tentar usar otabele até daphocusmas oscroll` does not bring the same, being "hidden".

How can I solve?

  • I’ll try to see, I fixed the other one. But I didn’t have time to test every possible flaw and even remade it. I will post on Sunday that I have more time to assist in case problems occur.

  • possible duplicate of Navigate horizontal scroll by pressing tab . You could just mention this in the comments section of the answer that helped you solve the problem, that the answer would be updated with this option, instead of dragging the same question to a new question

1 answer

2

How scroll only navigates on input worthless, 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 quite simple. No focus attribute a null value to the input and store the old value in a placeholder.

In the blur I see if there was a value entry, if yes, I assign that new value to the placeholder.

So the input will be empty every time you press tab

Browser other questions tagged

You are not signed in. Login or sign up in order to post.