实现的直接html标签内定义属性。
html代码如下
<div data-animation="slide" data-easing="swing" data-direction="horizontal" data-smoothHeight="false" data-slideshowSpeed="4000" data-animationSpeed="500" data-pauseOnHover="true" data-controlNav="false" data-directionNav="false" data-isCarousel="true" data-itemWidth="184" data-itemMargin="0" data-minItems="1" data-maxItems="6" data-move="1" class="mk-clients-shortcode mk-script-call mk-flexslider mk-shortcode "><ul class="mk-flex-slides"><li><div title="TechCrunch CN" class="client-logo" style="background-image:url(http://xfounder.com/wp-content/uploads/2013/10/TC_logo_web.png); height:160px; background-color:#ffffff; border-color:#f4f4f4; "></div></li><li><div title="dianping" class="client-logo" style="background-image:url(http://xfounder.com/wp-content/uploads/2013/10/dianpinglogo.jpg); height:160px; background-color:#ffffff; border-color:#f4f4f4; "></div></li><li><div title="Cyberport" class="client-logo" style="background-image:url(http://xfounder.com/wp-content/uploads/2013/10/cyberportlogo.jpg); height:160px; background-color:#ffffff; border-color:#f4f4f4; "></div></li><li><div title="真格基金" class="client-logo" style="background-image:url(http://xfounder.com/wp-content/uploads/2013/10/zhenfund-logo.jpg); height:160px; background-color:#ffffff; border-color:#f4f4f4; "></div></li><li><div title="明道" class="client-logo" style="background-image:url(http://xfounder.com/wp-content/uploads/2013/10/mingdao-logo.png); height:160px; background-color:#ffffff; border-color:#f4f4f4; "></div></li><li><div title="Ravio" class="client-logo" style="background-image:url(http://xfounder.com/wp-content/uploads/2013/10/raviologo.jpg); height:160px; background-color:#ffffff; border-color:#f4f4f4; "></div></li><li><div title="VELVET" class="client-logo" style="background-image:url(http://xfounder.com/wp-content/uploads/2014/04/logo-velvet.png); height:160px; background-color:#ffffff; border-color:#f4f4f4; "></div></li><li><div title="CIC" class="client-logo" style="background-image:url(http://xfounder.com/wp-content/uploads/2014/04/logo-cic.png); height:160px; background-color:#ffffff; border-color:#f4f4f4; "></div></li><li><div title="科律律师事务所" class="client-logo" style="background-image:url(http://xfounder.com/wp-content/uploads/2014/04/cooley-logo.jpg); height:160px; background-color:#ffffff; border-color:#f4f4f4; "></div></li><li><div title="UBER" class="client-logo" style="background-image:url(http://xfounder.com/wp-content/uploads/2014/04/UBER2.jpg); height:160px; background-color:#ffffff; border-color:#f4f4f4; "></div></li></ul></div>
插件来源可以直接百度flexslider即可找到。
在引入jq和插件还有css后可以直接解析去运行。代码如下
function mk_flexslider_init() {
$('.mk-flexslider.mk-script-call').each(function() {
if ($(this).parents('.mk-tabs').length || $(this).parents('.mk-accordion').length) {
$(this).removeData("flexslider");
}
var $this = $(this),
$selector = $this.attr('data-selector'),
$animation = $this.attr('data-animation'),
$easing = $this.attr('data-easing'),
$direction = $this.attr('data-direction'),
$smoothHeight = $this.attr('data-smoothHeight') == "true" ? true : false,
$slideshowSpeed = $this.attr('data-slideshowSpeed'),
$animationSpeed = $this.attr('data-animationSpeed'),
$controlNav = $this.attr('data-controlNav') == "true" ? true : false,
$directionNav = $this.attr('data-directionNav') == "true" ? true : false,
$pauseOnHover = $this.attr('data-pauseOnHover') == "true" ? true : false,
$isCarousel = $this.attr('data-isCarousel') == "true" ? true : false;
if ($selector != undefined) {
var $selector_class = $selector;
} else {
var $selector_class = ".mk-flex-slides > li";
}
if ($isCarousel == true) {
var $itemWidth = parseInt($this.attr('data-itemWidth')),
$itemMargin = parseInt($this.attr('data-itemMargin')),
$minItems = parseInt($this.attr('data-minItems')),
$maxItems = parseInt($this.attr('data-maxItems')),
$move = parseInt($this.attr('data-move'));
} else {
var $itemWidth = $itemMargin = $minItems = $maxItems = $move = 0;
}
$this.flexslider({
selector: $selector_class,
animation: $animation,
easing: $easing,
direction: $direction,
smoothHeight: $smoothHeight,
slideshow: true,
slideshowSpeed: $slideshowSpeed,
animationSpeed: $animationSpeed,
controlNav: $controlNav,
directionNav: $directionNav,
pauseOnHover: $pauseOnHover,
prevText: "",
nextText: "",
itemWidth: $itemWidth,
itemMargin: $itemMargin,
minItems: $minItems,
maxItems: $maxItems,
move: $move,
});
});
}
这里源码想共享出来。但发现离线编辑器发不了源码。需要源码的可以加我微信。