[ / / / / / / / / / ] [ dir / ask / dcaco / fur / hypno / o / sl / ttgg / u ][Options][ watchlist ]

/prog/ - Programming

Programming board

Catalog

You can now write text to your AI-generated image at https://aiproto.com It is currently free to use for Proto members.
Name
Email
Subject
Comment *
File
Select/drop/paste files here
* = required field[▶ Show post options & limits]
Confused? See the FAQ.
Expand all images

[–]

000000 (2) No.3115[Watch Thread][Show All Posts]

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.

82ea2f (1) No.3118>>3125

1. You're missing a curly brace.

2.


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

change this to var post and var name.


49efab (1) 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 (2) No.3134

use a fucking debugger dude

/winter




[Return][Go to top][Catalog][Screencap][Update] ( Scroll to new posts) ( Auto) 5
3 replies | 0 images | 3 UIDs | Page ?
[Post a Reply]
[ / / / / / / / / / ] [ dir / ask / dcaco / fur / hypno / o / sl / ttgg / u ][ watchlist ]