[ home / board list / faq / random / create / bans / search / manage / irc ] [ ]

/prog/ - Programming

Programming board

Catalog

8chan Bitcoin address: 1NpQaXqmCBji6gfX8UgaQEmEstvVY7U32C
The next generation of Infinity is here (discussion) (contribute)
A message from @CodeMonkeyZ, 2ch lead developer: "How Hiroyuki Nishimura will sell 4chan data"
Name
Email
Subject
Comment *
File
* = required field[▶ Show post options & limits]
Confused? See the FAQ.
Embed
(replaces files and can be used instead)
Options
Password (For file and post deletion.)

Allowed file types:jpg, jpeg, gif, png, webm, mp4, pdf
Max filesize is 8 MB.
Max image dimensions are 10000 x 10000.
You may upload 1 per post.


000000 No.3115

Why isn't this working?!


$(document).ready(function () {
function spamDetect(post) {
var $post = $(post);
var $name = $post.find('.name');
var hasEmail = $post.find('.email').length > 0;
if (hasEmail) {$name.text('SAGE');}
});

Pls help good anons.

17e0bd No.3118

1. You're missing a curly brace.

2.


var $post = $(post);
var $name = $post.find('.name');

change this to var post and var name.


3014fd No.3125

What >>3118 said, except that a dollar sign in front of jQuery elements is considered proper and correct, so keep using that. I would like to add, though, that you would probably appreciate using CoffeeScript:

$ ->
spamDetect = (post) ->
$post = $(post)
$name = $post.find '.name'
$name.text 'SAGE' if $post.find('.email').length > 0

It compiles to JavaScript through Node.js, which any seasoned web developer should already be using, and should only take a couple minutes to set up and get going.

If you are already familiar with Python, and like the language, you will definitely find CoffeeScript to be enjoyable.


000000 No.3134

use a fucking debugger dude

/winter




[Return][Go to top][Catalog][Post a Reply]
Delete Post [ ]
[]
[ home / board list / faq / random / create / bans / search / manage / irc ] [ ]