所以这是非常简单的,但我仍然是相当新的JavaScript,只是找到了JSFiddle.我正在尝试使用getElementById()禁用和启用按钮来查找元素.我错过了什么?
<form name="frm" >
<div id="chkObj">
<input type="checkbox" name="setChkBx" onclick="basicList.modifyAndEnableButton(this)"></input>
</div>
<div id="Hello">
<input type="button" name="btn" value="Hello"></input>
</div>
Run Code Online (Sandbox Code Playgroud)
这是我用来添加复选框的列表,因为会有多个复选框:
var basicList = {
'items': {},
'modifyAndEnableButton': function(obj1) {
var element = document.getElementsByName("btn");
if (obj1.checked == true && element.getAttribute('disabled') == false) {
element.getAttribute('disabled') = true;
this.addRecord(obj2);
} else if (element.getAttribute('disabled') == true) {
if (hasItems == false) {
element.getAttribute('disabled') = false;
}
}
}
};
Run Code Online (Sandbox Code Playgroud)
http://jsfiddle.net/Arandolph0/E9zvc/3/
在此先感谢您的帮助.
我是Gradle的新手,所以我正在尝试构建一个Java项目并且不确定依赖项.我从来没有让Gradle配置为能够进行我的测试或现在是一个jar文件来编译和运行.
我的build.gradle:
apply plugin: 'java'
apply plugin: 'maven'
repositories {
jcenter()
}
dependencies {
compile 'org.slf4j:slf4j-api:1.7.25'
compile 'org.json:json:20160212'
testCompile 'junit:junit:4.12'
}
Run Code Online (Sandbox Code Playgroud)
这就是我在控制台上得到的声明,它没有看到我的导入:
error: package org.json.simple does not exist
import org.json.simple.JSONParser;
Run Code Online (Sandbox Code Playgroud)
这是我的班级:
import org.json.simple.*;
import java.io.*;
import java.util.*;
import java.lang.*;
public class FileLoader {
@SuppressWarnings("unchecked")
public static void main(String args[]) {
JSONParser parser = new JSONParser();
int count = 0;
try {
Object obj = parser.parse(new FileReader(
"Consumers.json"));
JSONObject jsonObject = (JSONObject) obj;
JSONArray array = jsonObject.getJSONArray("people");
} catch …Run Code Online (Sandbox Code Playgroud) 我第一次使用Groovy和Grails并且无法让本地Windows 7环境接受到bin的路径的正确位置.至少我想在关注www.grails.org\Installation之后.
以下是提示反馈显示的内容:
C:\Groovy Grails\grails-1.3.7>gradlew
ERROR: JAVA_HOME might be set to an invalid directory: C:\Program Files\Java\jdk
1.7.0_03\bin;
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation if there are problems.
Run Code Online (Sandbox Code Playgroud)
该系统找不到指定的路径.
有什么建议去grails吗?
我只是想完全理解一个错误,因为有时候我可以绕过它,有时候我不能.我试过写一个函数:
function toggleButton() {
}
Run Code Online (Sandbox Code Playgroud)
但我得到了同样的错误.这是.js样本.
var checkBox = document.getElementById("chkMyBox");
checkBox.onclick = function toggleButton(e, obj1)
{
var btnElement = document.getElementById("btnMyButton");
if(btnElement != null) {
alert("Element not null");
if(e.target.checked && obj1 != null) {
alert("Checking check " + obj1.checked);
if(obj1.checked == true && btnElement.getAttribute('disabled') == false){
btnElement.getAttribute('disabled') = false;
} else {
btnElement.getAttribute('disabled') = true;
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是html:
<form id="frmCheckBox">
<input type="checkbox" id="chkMyBox" />
<button id="btnMyButton" disabled>I'm a Button</button>
</form>
Run Code Online (Sandbox Code Playgroud)
html ×2
javascript ×2
build.gradle ×1
dependencies ×1
events ×1
gradle ×1
grails ×1
java ×1
json-simple ×1
junit ×1