选中输入复选框后,我想附加<div>一条消息.但不知何故,我的代码似乎不起作用.我在这里错过了什么吗?
这是我到目前为止的链接 - http://jsbin.com/petewadeho/edit?html,output
<script src="https://code.jquery.com/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="https://gitcdn.github.io/bootstrap-toggle/2.2.2/js/bootstrap-toggle.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="https://gitcdn.github.io/bootstrap-toggle/2.2.2/css/bootstrap-toggle.min.css" rel="stylesheet">
<input id="inp" type="checkbox" data-toggle="toggle" />
<div id="out"></div>
<script>
$('#inp').click(function() {
if (this.checked) {
$("#out").append("hey");
}
});
</script>Run Code Online (Sandbox Code Playgroud)
我有一个API 结果给出这样的时间戳1447804800000.如何使用Javascript/jQuery将其转换为可读格式?
我正在尝试验证String包含一个人的名字和姓氏的 a 。可接受的名称格式如下。
Bruce Schneier \nSchneier, Bruce\nSchneier, Bruce Wayne\nO\xe2\x80\x99Malley, John F.\nJohn O\xe2\x80\x99Malley-Smith\nCher\nRun Code Online (Sandbox Code Playgroud)\n\n我想出了以下程序来验证字符串变量。如果名称格式与任何提到的格式匹配,该validateName函数应该返回。true否则它应该返回false。
import java.util.regex.*;\n\npublic class telephone {\n\n public static boolean validateName (String txt){\n String regx = "^[\\\\\\\\p{L} .\'-]+$";\n Pattern pattern = Pattern.compile(regx, Pattern.CASE_INSENSITIVE);\n Matcher matcher = pattern.matcher(txt);\n return matcher.find();\n\n }\n\n public static void main(String args[]) {\n\n String name = "Ron O\xe2\x80\x99\xe2\x80\x99Henry";\n\n System.out.println(validateName(name));\n\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n\n但由于某种原因,它正在返回false任何值。我在这里做错了什么?
我有一个像这样的JSON文件,
JSON文件
{
"reviewerID": "A7S2B0I67WNWB",
"asin": "0594481813",
"reviewerName": "AllyMG",
"helpful": [2, 2],
"reviewText": "This item is just as was described in the original description, works without any issues to be seen. Good product",
"overall": 4.0,
"summary": "As expected",
"unixReviewTime": 1397606400,
"reviewTime": "04 16, 2014"
}
{
"reviewerID": "A3HICVLF4PFFMN",
"asin": "0594481813",
"reviewerName": "Amazon Customer",
"helpful": [0, 0],
"reviewText": "bought for a spare for my 9" Nook HD and it fit perfectly. Very satisfied with the price much less than on the …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Android Studio 中的 autocompletetextview 为用户键入的每个字母提供建议。
每次键入字母时,都会像这样进行 API 调用,
http://dev.markitondemand.com/MODApis/Api/v2/Lookup/json?input=app
http://dev.markitondemand.com/MODApis/Api/v2/Lookup/json?input=appl
http://dev.markitondemand.com/MODApis/Api/v2/Lookup/json?input=apple
Run Code Online (Sandbox Code Playgroud)
从 API 调用返回的 JSON 数组填充在建议列表框中。
到目前为止,我得到了这样的activity_main.xml文件,
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.raam.stockmarketviewer.MainActivity">
<AutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/stocks"
android:hint="@string/hint" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
在此之后,我应该如何构建MainActivity.java文件以完成自动建议功能?
我有一个像这样的空星按钮,
<button type="button" class="btn btn-default btn-lg" id="refresh">
<span class="glyphicon glyphicon-star-empty"></span>
</button>
Run Code Online (Sandbox Code Playgroud)
当我单击它时,我希望内部颜色变为黄色,如下所示 - http://s21.postimg.org/3qwgsnrcj/star.png
我们如何使用 Bootstrap 和 Javascript 实现这一点?
这是我到目前为止所获得的链接 - http://jsbin.com/refatlefi/edit?html,output
我有一个包含两个单选按钮和一个 textarea 的表单。textarea 最初是禁用的。当用户选择“自定义消息”单选按钮时,disabled 属性将被删除,textarea 变为可编辑。
现在,如果用户选择“虚拟消息”单选按钮,则文本区域应再次禁用。
到目前为止,我有这个代码,
document.getElementById('customMessageRadioButton').addEventListener('change', function() {
if (document.getElementById('customMessageRadioButton').checked) {
document.getElementById('customMessageTextArea').removeAttribute("disabled");
document.getElementById('customMessageTextArea').focus();
}
if (!document.getElementById('customMessageRadioButton').checked) {
document.getElementById('customMessageTextArea').setAttribute("disabled", "true");
}
});Run Code Online (Sandbox Code Playgroud)
<input name="group1" id="dummy" type="radio" />Dummy Message
<input name="group1" id="customMessageRadioButton" type="radio" />Custom Message
<textarea disabled id="customMessageTextArea"></textarea>Run Code Online (Sandbox Code Playgroud)
我在这里面临的问题是在这种情况下 - 当我首先选择“自定义消息”单选按钮然后返回并选择“虚拟消息”单选按钮时,文本区域没有被禁用。
这是我的JS Bin
PS我不能使用jQuery。必须只使用 vanilla Javascript。
我有以下代码,当用户将鼠标悬停在复选框上时,它会在复选框上显示工具提示,
<input type="checkbox" data-toggle="toggle" rel="tooltip" data-placement="bottom" title="Automatic Refresh" />
<script type="text/javascript">
$(document).ready(function(){
$('[rel="tooltip"]').tooltip();
});
</script>
Run Code Online (Sandbox Code Playgroud)
但是当我从Bootstrap Toggle添加这些库插件以使复选框成为滑动开关时,工具提示停止显示。
<link href="https://gitcdn.github.io/bootstrap-toggle/2.2.2/css/bootstrap-toggle.min.css" rel="stylesheet">
<script src="https://gitcdn.github.io/bootstrap-toggle/2.2.2/js/bootstrap-toggle.min.js"></script>
Run Code Online (Sandbox Code Playgroud)
这是我到目前为止所获得的链接 - http://jsbin.com/mepotaliti/edit?html,output
关于如何解决这个问题的任何想法?
java ×3
javascript ×3
jquery ×3
android ×1
autocomplete ×1
css ×1
datetime ×1
gson ×1
html ×1
json ×1
match ×1
names ×1
regex ×1
validation ×1