Sometimes you need to check that an element exists in your page before you target it with jQuery.
Here is a dead simple way I found. It may not be the best, if you have a better way hit me up in the comments.
if(('#element').length > 0){
// Put your cool code here
}
Posted in Javascript JQuery
Tagged with Javascript JQuery
The JQuery built in functions are great. They make some really cool effects possible really easily.
But occasionally you find something that just doesn’t seem to play properly.
Take the below example for instance. What I’d like to happen is that when the button is clicked div#one fades out slowly and then div#two pops in.
$("button").click(function(){
$("div#one").fadeOut("slow");
$("div#two")show();
});
Read More >
Posted in Javascript JQuery
Tagged with Javascript JQuery
The other day I was busily building a web application that uses a lot of popup style modular windows and I had a thought.
Users expect certain things. Like the fact that the sun will come up in the morning and the fact that the escape key closes things that have opened. The only problem is that this escape key behavior doesn’t work in websites. Unless we tell it to that is.
So what do we need to do?
Well firstly I’ll be adding this functionality with the aid of JQuery so I’m assuming that you have that setup properly.
Now we need to detect the key stroke. Read More >
Posted in Javascript JQuery
Tagged with JQuery UX
Firstly to say that I can’t take credit for this bit of code. I found it on the net at http://www.bunchacode.com/programming/load-jquery-for-firebug-console/
Today I suddenly found that my console.log(); debugging lines in JQuery were not writing out to the console in Firefox.
Read More >
Posted in Javascript
Tagged with JQuery