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
Category Archives: jQuery
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
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()
jQuery UI Drag and Drop Example
The following html makes use of the jQuery UI to implement a simple drag and drop feature. Make sure you have download the jQuery UI and put those files in the correct directory. Continue reading jQuery UI Drag and Drop Example
jQuery – Wrap children div with Page Number and Index
jQuery can be used to modify the html before it is rendered in the browser. In the following example, i will wrap those children div with page number and index. Then we can apply css on those newly created div for better layout. Continue reading jQuery – Wrap children div with Page Number and Index