开发者

Why this jsfiddle wont run?

开发者 https://www.devze.com 2023-03-23 00:06 出处:网络
This is开发者_开发百科 probably a stupid mistake, but I\'m new to jsFiddle, and I can\'t run this piece of code:

This is开发者_开发百科 probably a stupid mistake, but I'm new to jsFiddle, and I can't run this piece of code: my fiddle

The code should put either OK or not ok in the .output div. It doesn't do it. Thanks


Fixed. Your curr_year wasn't a string, and you forgot a ); at the end.


There's a couple of things.

Firstly you were missing a closing ) at the end of the code.

Secondly, you can't get a substring of a date type. You need to convert it to a string first:

http://jsfiddle.net/rnG4n/6/

If you have a look in the Error console in your browser you'll see the problems as they arrise.


Two problems:

  • You forgot the enclosing ')' at the end of your javascript to close $(function() {
  • You tried calling substr on curr_year which is a date, not an string.

Fixed your fiddle: http://jsfiddle.net/rnG4n/4/

0

精彩评论

暂无评论...
验证码 换一张
取 消