Create jQuery objects from Zen Coding abbreviation.
Download jquery.zencoding-v0.6-0.9.zip and extract jquery.zencoding.min.js from the archive.
Include jQuery and Zen Coding plugin from the HTML file. Create jQuery object from the Zen Coding abbreviation like this.
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script>
<script type="text/javascript" src="jquery.zencoding.min.js"></script>
<script type="text/javascript">
$(function() {
// Create jQuery object from the abbreviation by $.zenCoding function,
// and append the jQuery object to the bottom of the body.
var obj = $.zenCoding('div#page>div.logo+ul#navigation>li*5>a');
$('#d1').append(obj);
// The following code is same as adove. zenCoding function of jQuery object
// append the abbreviation to the selected object.
$('#d2').zenCoding('div#page>div.logo+ul#navigation>li*5>a');
});
</script>
</head>
<body>
<div id="d1"></div>
<div id="d2"></div>
</body>
</html>
jQuery.zenCoding plugin provides two functions, $.zenCoding and $.fn.zenCoding.
Create jQuery objects from the Zen Coding abbreviation.
Append the Zen Coding abbreviation expanded jQuery object.
$(selector).zenCoding function expands Zen Coding abbreviation.
The following code expand the abbreviation to #replace element.
$('#replace').zenCoding('div#page>div.logo+ul#navigation>li*5>a');
The following is expanded elements. (Use Firefox and Firebug to visualize the processing result.)
You can get the expanded abbreviation by $.zenCoding function.
var s = $.zenCoding({
abbr: 'div#page>div.logo+ul#navigation>li*5>a',
resultType:'text'
});
$('#code').val(s);
The following textarea contains expanded HTML contents of the abbreviation.
This plugin includes core files of the Zen Coding Project.