Many latest framework are loading all javascript in footer. They reduce the page loading the errors. But wordpress load the jquery and other javascript in header.
loading javascript libraries in footer will be always best for every web or mobile application. Here in this article, I will show to Load jQuery in wordpress footer section.
But using following code you can load your javascripts and jquery in footer area. You just need to copy and paste the following code into the functions.php file.
Load jQuery in wordpress footer section
function wpai_add_jquery_in_footer( &$scripts) {
if ( ! is_admin() )
$scripts->add_data( 'jquery', 'group', 1 );
}
add_action( 'wp_default_scripts', 'wpai_add_jquery_in_footer' );
After doing the this you js scripts will load in footer. This js will load in footer for only normal users, Not for admin user.
wordpress and jquery both are powerful tool. In plugin we need datepicker sometime. In this article i showed how to implement jquery UI datepicker in wordpress
implement jquery UI datepicker in wordpress
Some WP developers use the plugins to add the datepicker in wordpress. But you can add the Jquery datepicker in wordpress. How can use the Jquery UI in your wordpress theme and plugin using following code. For adding the datepicker in theme you need to just add the following code in functions.php file.
[viral-lock message=”Some Source code is Hidden! It’s Visible for Users who Liked/Shared This article on Facebook or Twitter or Google+. Like or Tweet this article to reveal the content.”]
WordPress Tutorial, add css and javascript file to admin in wordpress theme. Many developers want to add the javascript and css files into wordpress themes.
add css and javascript file to admin in wordpress theme
You just need to add following code into functions.php file.
// Register your javascript for properties
function admin_your_javascript(){
global $post;
if($post->post_type == 'post-type' && is_admin()) {
wp_enqueue_script('YOUR-JS', WP_CONTENT_URL . '/themes/YOUR-THEME/js/YOUR-JS.js');
}
}
add_action('admin_print_scripts', 'admin_your_javascript');
// Register your styles for properties
function admin_your_styles(){
global $post;
if($post->post_type == 'post-type' && is_admin()) {
wp_enqueue_style('YOUR-CSS', WP_CONTENT_URL . '/themes/YOUR-THEME/css/YOUR-CSS.css');
}
}
add_action('admin_print_styles', 'admin_your_styles');
You just need to replace Your theme name and javascript and css file name.
Jquery is most powerful javascript framework and which is used widely. WordPress is most powerful and famous cms in the world. When you are using the jquery in wordpress that time you need to keep in mind some issues. WordPress itself uses the jquery in there framework. But when we tries to add the different versions of jquery and there plugins, there was issue or conflict with jquery. Sometimes I saw issue with some plugins due to different versions of jquery. I shown in this tutorial, how to solve the wordpress and jquery conflicts easily.
wordpress and jquery conflicts – How to solve that
Many people written the jquery wrapper around the jquery. They written in different style but when some jquery developers written or used same function name or same methods then jquery conflicts is happening.
WordPress itself uses the jquery for custom purpose. So you dont need to add the jquery script again in to wordpress. you just need to put following code in your wordpress theme for adding the jquery in your theme.
<!--?php wp_enqueue_script("jquery"); ?-->
Just put above lines in your header.php file for adding the jquery into your wordpress theme.
For removing the conflicts when you are using the jquery functions. just use following noconflict code in that.
$.noConflict();
// Code that uses other library's $ can follow here.
This technique is especially effective in conjunction with the .ready() method’s ability to alias the jQuery object, as within callback passed to .ready() we can use $ if we wish without fear of conflicts later:
<script type="text/javascript">// <![CDATA[
$.noConflict();
jQuery(document).ready(function($) {
// Code that uses jQuery's $ can follow here.
});
// Code that uses other library's $ can follow here.
// ]]></script>
Following is the some example for remove the conflicts from jquery with wordpress.
Just use the jquery multiple times for each jqeury plugins. That is the easiest way to solve the jquery conflicts.
But if you are having some knowledge of jquery then use the following code for remove the conflict.
var j = jQuery.noConflict();
// Do something with jQuery
j("div p").hide();
// Do something with another library's $()
$("content").style.display = 'none';
For many purpose we use the jquery in wordpress. Mainly jquery is used for sliders and menu and gallery.
For menu or slideshow use jquery in following fashion.
[viral-lock message=”Solution code is Hidden! It’s Visible for Users who Liked/Shared This article on Facebook or Twitter or Google+. Like or Tweet this article to reveal the content.”]
<script type="text/javascript">// <![CDATA[
$.noConflict();
jQuery(document).ready(function($) {
// Code that uses jQuery's $ can follow here.
});
// Code that uses other library's $ can follow here.
// ]]></script>
[/viral-lock]
If you still facing issue with jquery then please write to me on support@purabtech.in.
Here are some useful resources and links about Jquery and wordpress.
Jquery is most popular and used javascript library which is used for multiple purpose. Every developer is using CSS and Jquery for modifying the UI and usability. Here I collected the more then 100 jquery and CSS techniques and tips and tutorials in this article. This articles are useful for every Jquery developers.
We collected the more then 100 jquery and CSS techniques and tutorials in this article.
Photo Zoom Out Effect with jQueryJquery is most popular and used javascript library which is used for multiple purpose. Every developer is using CSS and Jquery for modifying the UI and usability. Here I collected the more then 100 jquery and CSS techniques and tips and tutorials in this article. This articles are useful for every Jquery developers.
Interactive Photo Desk with jQuery and CSS3
In this little experiment you will create an interactive photo desk that provides some “realistic” interaction possibilities for the user. The idea is to have some photos on a surface that can be dragged and dropped, stacked and deleted, each action resembling the real world act.
By using the jQuery Color plugin, you can animate colors. Simply use the animate() function from jQuery to have colours fade to another colour. When using this technique, combined with some CSS3 features (rounded corners and drop shadow), you can create a Colorful rating system.
Remember jTypingHero? This was a fun little game to test your typing skills based on the ever popular Guitar Hero. By combining CSS3 and jQuery, you will create, in this experimental tutorial, two records that you can start spinning (faster and slower) and even scratching is enabled.
In this quick tutorial, the developer is going to explain how you can have a nicely floated list of items and you will use jQuery to make sure IE understands it too.
In this tutorial you are going to create an awesome image gallery which leverages the latest CSS3 and jQuery techniques. The script will be able to scan a folder of images on your web server and build a complete drag and drop lightbox gallery around it.
CSS3 Glow Tabs
You will learn how to recreate the ‘hover glow tabs’ from the jQuery Conference page, which has a nice “glowing” rollover effect along with a subtle inner shadow at the bottom of the inactive tabs and also applied some rounded corners and gradients to complete a very nice effect.
Recreating the MLB.com Content Switcher
The goal of this project is to try to recreate the Flash content switcher from MLB.com, using jQuery and CSS3 and without any extraneous images or other non-essential elements that tend to make stuff less maintainable.
Pretty Simple Content Slider
You will learn how to create an auto-playing content slider with jQuery and CSS3. The idea is to alter the background image and to slide in the heading and the description. By clicking on one of the menu items, the auto-play function is stopped and the respective content slides out.
In this tutorial you will learn how to recreate a variation of MS Words (2007) toolbar that exposes context-related functionality. When user makes a selection in the input field, a Minibar pops up, semi-transparent, above the selection. It disappears when user clicks anywhere in the input field or performs an action by clicking on a Minibar button.
Making a Sleek Feed Widget With YQL, jQuery & CSS3
In this tut you will larn how to build a sleek feed widget, that will fetch any RSS feed and display it in your blog sidebar. You can set it to show the latest blog posts from different categorie, your latest stumbles, or it even display your Twitter mentions.
Awesome Image Gallery using CSS3 and jQuery
The simple CSS3 image gallery (with jQuery) you will be building will be slightly tilted to the side and on hover will move and whenever you click on the image a lightbox will pop out with the larger version of the image.
Kick-Ass jQuery & CSS3 Gallery With Animated Shine Effects
You will be shown how you can create a kick-ass animated Shine Effect with jQuery & CSS3 and then use it to create your very own Shiny Gallery ‘ShineTime’. This effect is useful in making your user interface elements look like they’re a real polaroid photo (or made of glass) and the best part is, it’s not that difficult to achieve.
A Sexy Vertical Sliding Panel Using jQuery And CSS3
Here you can learn how to make a vertical sliding panel that will act as some sort of drawer instead of the usual top horizontal sliding panel that pushes everything else down when it is open.
Pure CSS3 Bokeh Effect with some jQuery help
IThe bokeh effect is currently a very popular trend amongst designers and in this unique tutorial you will learn how to create a pure CSS3 version of the effect. With some help from jQuery, you can add some randomness the the colors, sizes and vary the positions of the effect.
Create a Nifty Dynamic Shadow with jQuery
Here, Daniel Kurdoghlian, will show you how to recreate the very nifty looking dynamic shadow effect he created for his very popular CSS3 and jQuery experiment. He walks you through every step of the tutorial by using a few teaspoons of jQuery, a pinch of CSS and some transparent PNG’s as Base.
Create A Multiple URL Shortener Page
In this tutorial, you’ll be shown how to create a simple page that will show short urls created by multiple url shortener services. You’ll be using HTML5, CSS3 for styling as well as jQuery for working with Ajax.
In this tutorial you will learn how to build a Simple AJAX Commenting System. It will feature a gravatar integration and demonstrate how to achieve effective communication between jQuery and PHP/MySQL with the help of JSON.
Beautiful Looking Custom Dialog Box With jQuery and CSS3
This dialog box uses CSS3 drop shadow and a completely CSS3 styled button. So, latest version of Chrome, Firefox and Safari will have no problems with it, but for IE6 and 7, the script will work but the display of the dialog box will look plain, no rounded border, drop shadow and gradient.
Making a Mosaic Slideshow With jQuery & CSS
When designing a product page, it is often necessary to present a number of images in a succession, also known as a slideshow. In this technique you will be making a jQuery & CSS mosaic gallery, featuring an interesting tile transition effect when moving from one slide to another.
Beautiful Photo Stack Gallery with jQuery and CSS3
In this tutorial you are going to create a nice and fresh image gallery. The idea is to show the albums as a slider, and when an album is chosen, you show the images of that album as a beautiful photo stack. In the photo stack view, you can browse through the images by putting the top most image behind all the stack with a slick animation.
Interactive Image Vamp up with jQuery, CSS3 and PHP
In this technique you will be shown how to create an online application for giving some funny touches to an image, using jQuery and jQuery UI for dragging and resizing little bling elements like mustaches and glasses. With PHP the image and the bling elements will get merged and the end result can be viewed.
CSS3 & jQuery Image Effects Image Highlighting and Preview with jQuery
In this tutorial you will be shown how to highlight and preview images that are integrated in an article or spread over a page. This is a nice way to allow users to view a bigger version of an image that is relevant to some context.
CSS3 Rounded Image With jQuery
In this tutorial you will learn how to give an image rounded corners using the CSS3 border-radius and box-shadow properties and using jQuery to automatically wrap a span tag around the image.
CSS3 & jQuery Menu and Navigation Tutorials Contextual Slideout Tips With jQuery & CSS3
With this tut you will learn how to make a set of contextual slideout tips with jQuery & CSS3, which are ideal for product pages and online tours. As a bonus, they are SEO friendly, so all the content is visible to search engines.
Elegant Accordion with jQuery and CSS3
Here you will create an elegant accordion for your sites content. The idea is to have some vertical accordion tabs that slide out when hovering. You will add some CSS3 properties to enhance the looks.
In this tutorial you will create a unique bottom slide out menu. This large menu will contain the title and a description of the menu item and it will slide out from the bottom revealing the description text and icons. You will use some CSS3 properties for some nice shadow effects and jQuery for the interaction.
Sweet AJAX Tabs
Organizing the content of a page in a both intuitive and eye-catching manner, is a must in modern web design. One principle that has been around for some time is dividing text into tabs. In this tutorial you will be making an AJAX-powered tab page with CSS3 and version 1.4 of jQuery
Mac-style Skype Application Menu
Using CSS3 and jQuery for extra functionality you will learn how to recreate the amazing slick Skype (for Mac) layout. (Not the full layout: Only the menu where all your friends are listed).
Halftone Navigation Menu
In this tut you will be making a CSS3 & jQuery halftone-style navigation menu, which will allow you to display animated halftone-style shapes in accordance with the navigation links, and will provide a simple editor for creating additional shapes as well.
Create Accordion Menu Using CSS3 Transitions
There are many ways to create an accordion menu, most of them use a javascript library like jQuery to make the effect runs cross browsers. In this tutorial, you’ll see how to make an accordion
substr() javascript method extracts characters from a string. Here is working example for substr function. solved issue, substr not working in IE browser
substr not working in IE browser – issue solved
var str="Hello world!";
document.write(str.substr(3)+"<br />");
document.write(str.substr(3,4));
</script>
This function works with following browser.
Firefox
Safari
Opera
google chrome
There is issue with IE browser. Do not use the substr javascript method – this function is not working in IE browser.
You need to use the substring() method. This is similar to substr. You can achieve your work by using this method.
Following is the working example of substring method.
<script type="text/javascript">
var str="Hello world!";
document.write(str.substring(3)+"<br />");
document.write(str.substring(3,7));
</script>
Many times we need the fadein and fadeout effect using javascript. Javascript tutorial for, Fadein and Fadeout effect through javascript example. But many developers go for jquery for using simple fadein and fadeout effect
Fadein and Fadeout effect through javascript example
I suggest not to Jquery and Use following code for effect. This is very minimal code and you can very easily customize the CSS and javascript as per your requirement.
<html>
<head>
<style type="text/css">
.popup {
border: solid 1px #333;
font-family: Tahoma;
font-size: 12px;
display: none;
position: absolute;
width: 300px;
z-index: 60;
}
.popuptitle {
background: blue;
color: white;
font-weight: bold;
height: 15px;
padding: 5px;
}
.popupbody {
background: #ddd;
padding: 5px;
text-align: center;
}
#popup1 { top: 100px; left: 50px; }
#popup2 { top: 100px; left: 400px; }
</style>
<script type="text/javascript">
var fadeOpacity = new Array();
var fadeTimer = new Array();
var fadeInterval = 100; // milliseconds
function fade(o,d)
{
// o - Object to fade in or out.
// d - Display, true = fade in, false = fade out
var obj = document.getElementById(o);
if((fadeTimer[o])||(d&&obj.style.display!='block')||(!d&&obj.style.display=='block'))
{
if(fadeTimer[o])
clearInterval(fadeTimer[o]);
else
if(d) fadeOpacity[o] = 0;
else fadeOpacity[o] = 9;
obj.style.opacity = "."+fadeOpacity[o].toString();
obj.style.filter = "alpha(opacity="+fadeOpacity[o].toString()+"0)";
if(d)
{
obj.style.display = 'block';
fadeTimer[o] = setInterval('fadeAnimation("'+o+'",1);',fadeInterval);
}
else
fadeTimer[o] = setInterval('fadeAnimation("'+o+'",-1);',fadeInterval);
}
}
function fadeAnimation(o,i)
{
// o - o - Object to fade in or out.
// i - increment, 1 = Fade In
var obj = document.getElementById(o);
fadeOpacity[o] += i;
obj.style.opacity = "."+fadeOpacity[o].toString();
obj.style.filter = "alpha(opacity="+fadeOpacity[o].toString()+"0)";
if((fadeOpacity[o]=='9')|(fadeOpacity[o]=='0'))
{
if(fadeOpacity[o]=='0')
obj.style.display = 'none';
else
{
obj.style.opacity = "1";
obj.style.filter = "alpha(opacity=100)";
}
clearInterval(fadeTimer[o]);
delete(fadeTimer[o]);
delete(fadeTimer[o]);
delete(fadeOpacity[o]);
}
}
</script>
</head>
<body>
popup1',true);"/>
popup2',true);"/>
popup1"></pre>
<div>Fade Popup 1</div>
<pre>
<div>
<p>Press close to fade out this Popup</p>
<input type="button" value="Close" onClick="fade('popup1',false);"/>
</div>
</div>
popup2"></pre>
<div>Fade Popup 2</div>
<pre>
<div>
<p>Press close to fade out this Popup</p>
<input type="button" value="Close" onClick="fade('popup2',false);"/>
</div>
</div>
</body>
</html>
Here in this article we discussed about ajax. We explored ajax history. As we know ajax is most useful and powerful tool in website development.
Really Simple History of Ajax
Ajax (pronounced /ˈeɪˌdʒæks/) (shorthand for Asynchronous JavaScript and XML) is a group of interrelated web development techniques used on the client-side to create interactive web applications. With Ajax, web applications can retrieve data from the server asynchronously in the background without interfering with the display and behavior of the existing page. The use of Ajax techniques has led to an increase in interactive or dynamic interfaces on web pages. Data is usually retrieved using the XMLHttpRequest object. Despite the name, the use of XML is not actually required, nor do the requests need to be asynchronous.
If you’re working on Ajax based websites, you’ll always face usability problems when users click on the Back or Forward buttons on the broswer. Using Really Simple History (RSH) allows you over come this issue.
The Really Simple History (RSH) framework makes it easy for AJAX applications to incorporate bookmarking and back and button support. By default, AJAX systems are not bookmarkable, nor can they recover from the user pressing the browser’s back and forward buttons. The RSH library makes it possible to handle both cases.
In addition, RSH provides a framework to cache transient session information that persists after a user leaves the web page. This cache is used by the RSH framework to help with history issues, but can also be used by your own applications to improve application performance. The cache is linked to a single instance of the web page, and will disappear when the user closes their browser or clear their browser’s cache.
RSH works on Internet Explorer 6+ and Gecko-based browsers, like Firefox. Safari is not supported.
We written this post and again we are publishing this post. drag and drop sortable list javascript. involving something like up/down arrows next to each item. The most heinous require server roundtrips for each modification.
drag and drop sortable list javascript
Various implementations of Drag & Drop sortable lists using JS and CSS.
“In Web applications I’ve seen numerous — and personally implemented a few — ways to rearrange items in a list. All of those were indirect interactions typically involving something like up/down arrows next to each item. Then I came across Simon Cozens’ example of rearranging a list via drag & drop. I was so inspired I had to try it out myself.”
If you want the nice slide animation effect with javascript. you can use following javascript. Here I am not using any third party javascript library for creating the slide effect. Slide effect with popup you can achieve with only javascript.
popup slide effect with only javascript
For In page popup slide effect you can use following JavaScript code.
and use the following javscript code in your document.
[viral-lock message=”Solution code is Hidden! It’s Visible for Users who Liked/Shared This article on Facebook or Twitter or Google+. Like or Tweet this article to reveal the content.”]
function movead(){
timerID = setInterval("mocontainer()", 50);
}
function mocontainer(){
var popup_element = document.getElementById('popup-container');
animate_moveit(popup_element,0,-5);
}
function animate_moveit(obj, x, y){
obj.style.left = parseInt(obj.style.left) + x +"px"
obj.style.top = parseInt(obj.style.top)+ y + "px"
}
[/viral-lock]
For changing the slide direction change the values in following line and put in to the mocontainer function
animate_moveit(popup-element,-5,0); – this is for right to left
animate_moveit(popup-element,0,-5); – bottom to top