Can't get jQuery hide working
Question by fearofawhackplanet
I need a sanity check as I’ve spent about an hour trying to figure this out!
getRows().each(function() {
alert(this); // alerts '[object HTMLTableRowElement]', nothing wrong here
this.hide(); // row not hidden - wtf?
alert('hidden'); // no alert - more wtf!
});
What can be wrong that calling hide() is bombing out?
Answer by Nick Craver
Inside the .each()
this
is a DOM element (HTMLTableRowElement
), you need to wrap it to make it a jQuery object again (which has the .hide()
method) like this:
$(this).hide();
Without this, you’re getting a method undefined error, because HTMLTableRowElement
doesn’t have the .hide()
method ๐ This error is also why the alert isn’t firing afterwards, because execution stopped on the error.
Answer by Starx
try $(this).hide()
Limit posting to every 30 minutes
Question by jay
Thanks for looking.
I’m trying to write a script to set a cookie after the user posts a comment, limiting them from posting again for 30 minutes. I’m so confused on where to start. Please, could you guys help me out on how I do this?
I’m trying to use this jquery plugin โ countdown timer.
Answer by Starx
Use Session
For example, after a post, put the current time + 30 minutes in your session line this
$_SESSION['postTimeFlag'] = time() + 1800;
Then whenever the user is about to post then the session