Why Simple JS Works on JSFiddle, but Not for Me

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
diseman
Forum Contributor
Posts: 174
Joined: Mon Jul 26, 2010 1:30 pm
Location: Florida

Why Simple JS Works on JSFiddle, but Not for Me

Post by diseman »

Hi Celauran,

I'm thinking you'll stumble on this and be able to help. This JS is not working on my localhost and wondering why. I've tried Chrome, Opera, and FF. No, I do not have javascript turned off in browsers.

REFERENCE: https://goo.gl/vELiXk
REFERENCE: http://jsfiddle.net/2VETF/3/

What I have:

Code: Select all

<!DOCTYPE HTML>

<html>

<head>

<title>Untitled</title>

<script>

$(function() {
    $(".inputs").keyup(function () {
        if (this.value.length == this.maxLength) {
          $(this).next('.inputs').focus();
        }
    });
});});

</script>

<style type="text/css">
<!--
input { width: 30px; margin: 5px;  }
-->
</style>

</head>

<body>
<input class="inputs" type="text" maxlength="4" />
<input class="inputs" type="text" maxlength="4" />
<input class="inputs" type="text" maxlength="4" />
<input class="inputs" type="text" maxlength="4" />
<input class="inputs" type="text" maxlength="4" />
<input class="inputs" type="text" maxlength="4" />
</body>

</html>
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Why Simple JS Works on JSFiddle, but Not for Me

Post by Celauran »

Looks like it depends on jQuery, which I don't see loaded.
User avatar
diseman
Forum Contributor
Posts: 174
Joined: Mon Jul 26, 2010 1:30 pm
Location: Florida

Re: Why Simple JS Works on JSFiddle, but Not for Me

Post by diseman »

Hey Celauran,

Sorry for the late reply. I just found your reply in my spam box for some reason.

Ok, thank you for the insight. Gonna go look now and see what's what.

Michael
Post Reply