This is another jQuery example which i want to share with you. Again, it maybe not good for use but it would be a nice example for beginners to take a quick look on jQuery. Try jQuery Cycle Plugin to get more interesting animation. If you are looking for more jQuery examples, take a look in my previous blog posts.
Tag Archives: jQuery
jQuery – Sliding div Example
There are some jQuery plugins such as jQuery Cycle Plugin which makes website animation simple. The following HTML is a sliding div example without using other plugins. it maybe not good for use but it would be a nice example for beginners to try the power of jQuery. Continue reading jQuery – Sliding div Example
jQuery – Check if a Checkbox is CHECKED
So many “check” in this post title. haha~
You can get the checkbox state by the the following jQuery. Continue reading jQuery – Check if a Checkbox is CHECKED
Javascript – Preload Images When the HTML Page is Loaded
With Javasript and jQuery, we could manipulate images at client side. For example, some images are shown on a mouse hover effect. But if that image is too large, there may be some latency before the image could be rendered. We’d better preload those images to minimize the time delay. Continue reading Javascript – Preload Images When the HTML Page is Loaded
jQuery – Sort Element
I found a very good example which demonstrate how to sort elements in HTML using jQuery. It is too perfect to make any changes of it. Try it by yourself. But please note that the sort() function only works in jQuery 1.3.2 or above. Continue reading jQuery – Sort Element
jQuery – Check if an option is selected in Select Box
The following HTML is an example to check if an option is selected in a select box. Continue reading jQuery – Check if an option is selected in Select Box
jQuery & Javascript – Capture the Browser or Tab Closed Event
I was working on a WordPress project which i need to clear the PHP session when the browser or browser tab is closed. Although Javascript provides the window.onbeforeunload event but it will be triggered even whenever you leave the website. Finally i got a simple solution from Daniel Melo in StackOverflow. The following code required jQuery and i have included the Google one in the HTML.
In your web root, create the js/check_browser_close.js. Continue reading jQuery & Javascript – Capture the Browser or Tab Closed Event
jQuery – Check Element Existence
Check the existence of an element by the following if condition.
if ($("#mydiv").length > 0) {
// do something if mydiv exists
}
Done =)
Reference: How to check whether an element exists using jQuery
jQuery – Cycle Plugin White Background Problem in Internet Explorer
The jQuery Cycle plugin is so helpful on showing animated slide show in your webpage. Check it out at the following website to find more details.
jQuery Cycle Plugin
But thanks Microsoft, it’s greatest product, Internet Explorer 7 and 8 has a bug when showing transparent png in the slide show. That is a white background would be added to the cycle element which block the background image. Add the following options when calling the cycle function. Continue reading jQuery – Cycle Plugin White Background Problem in Internet Explorer
jQuery & Javascript – Schedule a Function call by setTimeout()
In Javascript, you could schedule a function call using the setTimeout().
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.4.js"></script>
<script type="text/javascript">
$(document).ready(function() {
setTimeout(delayedAlert, 3000);
});
function delayedAlert() {
alert("Hello Eureka!");
}
</script>
</head>
<body>
<h1>Eureka!</h1>
</body>
</html>
Continue reading jQuery & Javascript – Schedule a Function call by setTimeout()