小编BIL*_*ILL的帖子

如何使用jQuery处理复选框的更改?

我有一些代码

<input type="checkbox" id="chk" value="value" />
<label for="chk">Value </label>
<br/>
<input type="button" id="But1" value="set value" />
<br />
<input type="button" id="But2" value="read checked" />
Run Code Online (Sandbox Code Playgroud)

JavaScript的:

$(document).ready(function () {
    console.log("Ready ...");
    registerHandlers();

    function registerHandlers() {
        $('#But1').click(function () {
            $('#chk').prop('checked', !$('#chk').is(':checked'));
        });
        $('#But2').click(function () {
            var chk1 = $('#chk').is(':checked');
            console.log("Value : " + chk1);
        });

        $('input[type="checkbox"]').change(function () {
            var name = $(this).val();
            var check = $(this).prop('checked');
            console.log("Change: " + name + " to " + check);
        });
    }
});
Run Code Online (Sandbox Code Playgroud)

如何使用jQuery处理复选框的更改?我需要把处理程序更改为选中的任何复选框.

[更新]

有一个复选框和几个按钮.每个按钮都可以更改复选框.如何捕捉更改复选框的事件? …

checkbox jquery

104
推荐指数
5
解决办法
28万
查看次数

如何在Java中正确获取线程名称?

我有这个类用于在Java中创建一个线程

package org.vdzundza.forms;

import java.awt.Graphics;
import java.awt.Graphics2D;

public class DrawThread extends Thread {
    private static final int THREAD_SLEEP = 500;
    public CustomShape shape;
    private Graphics g;

    public DrawThread(CustomShape shape, Graphics g) {
        this.shape = shape;
        this.g = g;
    }

    @Override
    public void run() {
        while (true) {
            try {
                Thread.sleep(THREAD_SLEEP);
                Graphics2D g2d = (Graphics2D) g;
                g2d.setColor(this.shape.getColor());
                g2d.fill(this.shape.getShape());
                System.out.println(String.format("execute thread: %s %s",
                        Thread.currentThread().getName(), this.getName()));
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

控制台将以下文本显示为输出

execute thread: red rectangle Thread-2
execute …
Run Code Online (Sandbox Code Playgroud)

java multithreading

24
推荐指数
2
解决办法
8万
查看次数

获取jQuery的href属性

我有一些表行

<tr class="b_row">
    <td>
        <div class="cpt">
            <h2>
                <a href="/ref/ref/1.html">example</a>
            </h2>
        </div>
    </td>
</tr>

<!--more elements -->

<tr class="b_row">
    <td>
        <div class="cpt">
            <h2>
                <a href="/ref/two/23.html">example N</a>
            </h2>
        </div>
    </td>
</tr>
Run Code Online (Sandbox Code Playgroud)

我需要在属性中获取超链接.我用这个脚本

function openAll()
{
    $("tr.b_row").each(function(){
    var a_href = $('div.cpt').find('h2 a').attr('href');
    alert ("Href is: " + a_href);
}
Run Code Online (Sandbox Code Playgroud)

问题:变量a_href总是/ ref/ref/1.html

each jquery get href attr

17
推荐指数
2
解决办法
12万
查看次数

如何以非递归方式重写Ackermann函数?

我有功能

public static int func(int M,int N){
    if(M == 0 || N == 0) return M+N+1;
    return func(M-1, func(M, N-1));
}
Run Code Online (Sandbox Code Playgroud)

如何用非递归样式重写它?也许,它实现了一些算法吗?

java non-recursive

16
推荐指数
3
解决办法
1万
查看次数

如何在PhpStorm IDE中注释多行?

我使用PhpStorm编辑Apache的PHP文件和配置文件.如何评论所选块并设置符号注释?我想要,例如,

   <Directory />
        Options FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
    </Directory>
Run Code Online (Sandbox Code Playgroud)

   #<Directory />
   #    Options FollowSymLinks
   #    AllowOverride None
   #    Order deny,allow
   #    Deny from all
   #</Directory>
Run Code Online (Sandbox Code Playgroud)

comments editor phpstorm

14
推荐指数
3
解决办法
2万
查看次数

在Eclipse中设置窗口背景JavaDoc

我有黑色背景色.如何更改JavaDoc窗口的背景颜色? 屏幕1

[UPDATE#1] 类似问题 http://www.eclipse.org/forums/index.php?t=tree&th=77817&

eclipse ubuntu colors

12
推荐指数
2
解决办法
5449
查看次数

如何在C#中解析URL中的用户凭据?

我有一些格式的链接:

http://user:pass@example.com
Run Code Online (Sandbox Code Playgroud)

如何获取用户并从此URL传递?

c# url parsing

12
推荐指数
2
解决办法
5651
查看次数

如何在AngularJS 1.3.15中同步测试动画?

我想我的版本1.2到1.3的angular-animate.js存在迁移问题.这是我的动画

'use strict';
angular.module('cookbook', ['ngAnimate'])
    .animation('.slide-down', function() {
        var NG_HIDE_CLASS = 'ng-hide';

        return {
            beforeAddClass: function(element, className, done) {
                alert('before add');
                if(className === NG_HIDE_CLASS) {
                    element.slideUp(done);
                }
            },
            removeClass: function(element, className, done) {
                if(className === NG_HIDE_CLASS) {
                    element.hide().slideDown(done);
                }
            }
        };
    });
Run Code Online (Sandbox Code Playgroud)

同步测试

'use strict';

describe('A Brief Look At Testing Animations(changed) - ', function() {
    var scope;
    var element;
    var $animate;
    var $rootElement;

    beforeEach(module('cookbook', 'ngAnimateMock'));

    describe('Synchronous testing of animations', function() {

        var animatedShow = false;
        var animatedHide = false;

        beforeEach(module(function($animateProvider) …
Run Code Online (Sandbox Code Playgroud)

javascript tdd jasmine angularjs

10
推荐指数
1
解决办法
698
查看次数

5
推荐指数
2
解决办法
5385
查看次数

[PHP]如何在没有实例化的情况下检查一个类是否继承了另一个类?

我有一些班级名字.如何检查一个类是否继承了另一个类而没有实例化它?

 if (!class_exists($controller)) //AND I have check type
        {

            $objectController = new IndexController();
            $objectController->index();
        }
Run Code Online (Sandbox Code Playgroud)

php types class

5
推荐指数
3
解决办法
4233
查看次数