Recently I was browsing through the jQuery subr reddit and noticed this question pop up. Since I am sure this is a pretty common question on “Why won’t my jQuery command work properly”, I figured I would give a shot at answering it.
Hey guys, I’m sure this has been answered before but I can’t seem to find anything by searching Google or /r/jquery.
I am a beginner with this so forgive me, but I can’t find an explanation to this anywhere and I’m curious. When I try to stop the default submit function of a form in the <head> tag of a .html file it won’t work, but when I copy and paste the same code into the <body> it works fine. Regardless of where I place it, it is always below the link to the jquery library. This is really confusing and I was hoping you guys could explain this for me. Thanks!
via jQuery <script> in <body> or *lt;head>.
Handling writing and updating objects in an iframe can be bothersome in most browsers. Sure things like jQuery tend to help, but not always.
A normal way to access a frame in jQuery is below:
Now, lets say you actually want to get another element inside of the frame, lets get the HEAD element.
Doing research on a recent project, I came across an article by Mike Alsup on a “jQuery Plugin Development Pattern”.
If you haven’t seen it already its worth a trip to learningjquery.com to checkout the implementation of his pattern.
“There are a few requirements that I feel this pattern handles nicely:”
- Claim only a single name in the jQuery namespace
- Accept an options argument to control plugin behavior
- -Provide public access to default plugin settings-
- Provide public access to secondary functions (as applicable)
- Keep private functions private
- Support the Metadata Plugin
- Allow for extending the object via callbacks (either hooks or events) as applicable
- Scope all selectors with the ‘this’ object
Eric Hynds on his blog the other day gave a very good run down of jQuery 1.5 Deferreds. From the post:
*quick note: I originally posted this on trulyevil.com. However its time to move sites and actually keep something up and running for a while.
Events seem daunting at first, but really jQuery makes them super simple. Events can be used to alter behavior or even have multiple events happen on a single state change.
We all know about events like click, onkeydown, onmousedown, onmouseover, etc. But you can fire custom events as well. First you need to understand how to fire events. You can do this by using the $().trigger() event through jQuery.