如何在复选框更改时运行函数?
我正在尝试编写小复选框替换函数 - 但我做错了.
码:
(function($) {
$.fn.checking = function() {
if ($('.checbox').prop('checked', false) === true) {
$('.new-checkbox').prop('id', 'unchecked');
} else {
$('.new-checkbox').prop('id', 'checked');
}
};
})(jQuery);
$(document).ready(function() {
$('.checkbox').wrap('<div class="checkbox-wrapper"></div>');
$('.checkbox-wrapper').append('<p class="new-checkbox">Blue = Checked, Red = Unchecked</p>');
$('.checkbox').checking();
$('.checbox').bind('change', function() {
$(this).checking();
});
});
Run Code Online (Sandbox Code Playgroud)
PlayGround:现场演示
我最近才发现了underscore.js的强大功能,对我提出建议的方法仍然是新手:
我如何从中得到:
[
[{
"name": "Type 2",
"id": 14
}],
[{
"name": "Type 1",
"id": 13
}, {
"name": "Type 3",
"id": 15
}],
[{
"name": "Type 2",
"id": 14
}],
[{
"name": "Type 1",
"id": 13
}]
]
Run Code Online (Sandbox Code Playgroud)
对此:
["Type 1","Type 2","Type 3"]
Run Code Online (Sandbox Code Playgroud)
即没有重复和"名称"属性.
任何建议非常感谢.
如何index number在WHILE循环中获取当前帖子?
$index_query = new WP_Query( array( 'post_type' => 'post', 'orderby' => 'modified', 'posts_per_page' => '-1', 'order' => 'DESC' ) );
while ( $index_query->have_posts() ) : $index_query->the_post();
// echo current post index number
endwhile;
Run Code Online (Sandbox Code Playgroud)
尝试了以下,但没有结果.
$index_query->post->current_post;
Run Code Online (Sandbox Code Playgroud)
任何建议非常感谢!
MongoDB是否能够在不进行多次查询的情况下为随机文档提供资金?
例如,我在将所有文档加载到集合中后在JS端实现,这很浪费 - 因此只是想检查一次db查询是否可以做得更好?
我在JS方面采取的路径:
两个主要缺点是我正在加载所有数据 - 或者我进行了多次查询.
任何建议都非常感谢
如何从'.each循环'内部创建一个数组并在循环之外使用它?
我的.each loop:
// Loop through all but button with class .apply
$('.profile-nav ul li a').not('.apply').each( function() {
// if currently loop through element has .cur class
if( $(this).hasClass('cur') ) {
//Get the first class of the match element
var ClassesToApply = $(this).prop('class').split(' ')[0];
}
//How can I create an array from all ClassesToApply?
//var arr = jQuery.makeArray(ClassesToApply);
// This will create an array, but with one element only
});
Run Code Online (Sandbox Code Playgroud)
如何从所有人创建一个数组var = ClassesToApply?
而且我怎么能用这个数组做点什么呢?例如
$( allClasses …
我可以使用具有自执行功能的回调吗?
如果是的话,你看过任何一个例子吗?
JavaScript自执行功能:
(function(){
//Do Stuff
})()
Run Code Online (Sandbox Code Playgroud) 我是jQuery的新手.
同时使用jQuery验证插件和cufon给了我很多时间.
基本上,我想在jQuery Validation完成它必须做的事情之后检测事件并在它之后直接调用Cufon.refresh().
$('#commentForm').validate({
rules: {
password: {
required: true,
minlength: 8,
maxlength: 8,
number: true
},
}
});
Run Code Online (Sandbox Code Playgroud)
我们期待<label class="error"> SOME TEXT </label>表单无效时.
一旦创建,我想在jQuery Validation创建的标签上使用Cufon.refresh(). 如何检测jQuery验证何时完成,并根据该事件调用某些内容?
任何帮助非常感谢.问候,Piotr
我有以下网址 www.webiste.com/Services/allservices.html
我怎么能用jQuery获取这个URL的一部分?
例如' services'
或'allservices.html'
任何建议都非常感谢.
如何检测该用户对此事件的"X"分钟和运行功能没有做任何事情?
例如
if( // no action from user for 'X' minutes) { //do stuff } ??
任何建议都非常感谢.
只是玩弄Wordpress / Contact Form 7.
是否可以在成功的电子邮件发送活动中添加自定义javascript功能?
javascript ×5
jquery ×5
wordpress ×2
cufon ×1
json ×1
lodash ×1
mlab ×1
mongodb ×1
random ×1
restangular ×1
while-loop ×1