Posts Tagged ‘jQuery’

Programming in jQuery Way

Saturday, November 15th, 2008 by hejian

Launching Code on Document Ready

$(document).ready(function(){
// Put your code here
});

Select box onchange trigger

$('#id_of_selectbox').change(function() {
// Put your code here
});

Determine if a ID exist

if ( $("#myid").length > 0 ) {
//do something
}

Get ID of a element

var currentId = $(this).attr('id');

Use the JQuery ui.tabs plugin to display AJAX Tabs
Create the HTML code:

<div id="tabs">
<ul>
<li><a href="#one">One</a></li>
<li><a href="#two">Two</a></li>
<li><a href="#three">Three</a></li>
</ul>
<div id="one">
content ...
</div>
<div id="two">
content ...
</div>
<div id="three">
content ...
</div>
</div>

Display the tabs:

$(document).ready(function() {
$('#tabs > ul').tabs();
})

This is just a simple tabs, also we can got a lot of effects such as:

$('#tabs > ul').tabs({ fx: { height: 'toggle' } });
$('#tabs > ul').tabs({ fx: { opacity: 'toggle' } });
$('#tabs > ul').tabs({ fx: { height: 'toggle', opacity: 'toggle' } });

Wordpress template made by HeJian