标签:
将函数包在红色字体内部,可以解决$符号与其他插件的冲突。
<script type="text/javascript">
(function($, window, document) {
//$(document).ready(function(){
var param_cats = $("input[name=‘category[]‘]:checked").val();
if(param_cats == null || param_cats == ‘‘) {
param_cats = ‘0‘;
}
else {
$(‘#ehp-topblogs-title‘).html(‘Top Blogs in ‘ + $("input[name=‘category[]‘]:checked").next().html() + ‘:‘);
// $(‘#ehp-topblogs-title‘).html(‘Top Blogs in All Categories:‘);
}
var post_data_top_loved = {
action: ‘top_loved‘,
item_cats: param_cats,
top_loved_nonce: top_loved_vars.nonce
};
$.post(top_loved_vars.ajaxurl, post_data_top_loved, function(response) {
$(‘#divBlogsGroup‘).html(response);
$(‘#span-blog-loading‘).delay(1500).hide();
});
// });
})(jQuery, window, document);
</script>
(function($, window, document) {}) jQuery 调用解决与其他javascript库冲突的写法
标签:
原文地址:http://www.cnblogs.com/zhangchenliang/p/4203367.html