我不是jQuery的专家,但我试图为我的应用程序创建一个小脚本.我想检查所有复选框,但它无法正常工作.
首先我尝试使用attr
,之后我尝试了,prop
但我做错了.
我先试了一下:
$("#checkAll").change(function(){
if (! $('input:checkbox').is('checked')) {
$('input:checkbox').attr('checked','checked');
} else {
$('input:checkbox').removeAttr('checked');
}
});
Run Code Online (Sandbox Code Playgroud)
但这没效果.
下一步:这比上面的代码效果更好
$("#checkAll").change(function(){
if (! $('input:checkbox').is('checked')) {
$('input:checkbox').prop('checked',true);
} else {
$('input:checkbox').prop('checked', false);
}
});
Run Code Online (Sandbox Code Playgroud)
这两个例子都不起作用.我试着谷歌搜索答案,但没有成功.
jsFiddle:http://jsfiddle.net/hhZfu/4/
谢谢
我正在编写一个简单的脚本,其中使用gmail帐户向自己发送电子邮件.
我从SwiftMailer的引用中修改了脚本,但是我没有得到任何结果.怎么了?
编辑:进一步调试后我发现了这个声明
$result = $mailer->send($message);
Run Code Online (Sandbox Code Playgroud)
导致代码失败(下面的回显不打印).
为什么是这样?只是导致消息未发送程序崩溃?:/
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<?php
require_once '/var/www/swift/lib/swift_required.php';
echo 'Mail sent <br />';
/* //create the transport
$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 587);
->setUsername('softrain.evaluaciones@gmail.com')
->setPassword('softrain1234')
;
*/
$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 587)
->setUsername('softrain.evaluaciones@gmail.com')
->setPassword('password')
;
echo 'line 40 <br />';
$mailer = Swift_Mailer::newInstance($transport);
$message = Swift_Message::newInstance('Wonderful Subject')
->setFrom(array('softrain.evaluaciones@gmail.com' => 'Evaluaciones'))
->setTo(array('softrain.evaluaciones@gmail.com'=> 'A name'))
->setBody('Test Message Body')
;
echo …
Run Code Online (Sandbox Code Playgroud) 我试图延迟在div中交换文本.它应该像文本的滑块/旋转木马一样操作.
我必须有错误的代码,因为最终的文本替换永远不会发生.
另外,我如何动画引入替换文本(例如,窗帘)?
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css" />
<script type="text/javascript">
$(document).ready(function() {
$("#showDiv").click(function() {
$('#theDiv').show(1000, function() {
setTimeout(function() {
$('#theDiv').html('Here is some replacement text', function() {
setTimeout(function() {
$('#theDiv').html('More replacement text goes here');
}, 2500);
});
}, 2500);
});
}); //click function ends
}); //END $(document).ready()
</script>
</head>
<body>
Below me is a DIV called "theDiv".<br><br>
<div id="theDiv" style="background-color:yellow;display:none;width:30%;margin:0 auto;">
This text is inside the Div called "theDiv".
</div><br>
<br>
<input type="button" id="showDiv" value="Show DIV"> …
Run Code Online (Sandbox Code Playgroud) 我正在开发一个javascript循环,随着循环的进展警告每个键值.
为了加快速度,我选中了"阻止此页面创建其他对话框"复选框.通常这只会抑制一个例程的弹出窗口,但它们没有回来.
在Google Chrome中,不再从该网站弹出alert()消息.其他网站,但不是那个网站.
以前有人听说过这个吗?
问:如何重置该站点的alert()消息?
我在 vs 代码中使用 create-react-app 和 yarn 2 创建了一个新项目。编辑器在导入每个已安装的库时抛出错误,如下所示:
找不到模块“react”或其相应的类型声明。
项目编译并成功运行,但错误仍然存在。当我将文件的扩展名更改为.js和.jsx 时。ts和.tsx,错误消失。我应该如何解决打字稿文件的这个问题?
typescript reactjs visual-studio-code create-react-app yarnpkg
我试图为可重复的查询添加延迟.
我发现.delay不是在这里使用的.相反,我应该使用setInterval或setTimeout.我试过了两个,没有任何运气.
这是我的代码:
<?php
include("includes/dbconf.php");
$strSQL = mysql_query("SELECT workerID FROM workers ORDER BY workerID ASC");
while($row = mysql_fetch_assoc($strSQL)) {
?>
<script id="source" language="javascript" type="text/javascript">
$(setInterval(function ()
{
$.ajax({
cache: false,
url: 'ajax2.php',
data: "workerID=<?=$row['workerID'];?>",
dataType: 'json',
success: function(data)
{
var id = data[0]; //get id
var vname = data[1]; //get name
//--------------------------------------------------------------------
// 3) Update html content
//--------------------------------------------------------------------
$('#output').html("<b>id: </b>"+id+"<b> name: </b>"+vname);
}
});
}),800);
</script>
<?php
}
?>
<div id="output"></div>
Run Code Online (Sandbox Code Playgroud)
代码工作正常,它按要求输出结果.它只是没有延迟的负载.时间和/或间隔似乎不起作用.
谁知道我做错了什么?
我有两个脚本.每个都在我们公司的不同子域上运行"Example.com".
Script #1 -- house.example.com
Script #2 -- bob.fred.example.com
Run Code Online (Sandbox Code Playgroud)
相同的域,不同的子域.
当一个特定元素出现时house.example.com
,我需要向运行的脚本发送一条消息bob.fred.example.com
由于Google扩展可以在扩展之间交换消息,因此必须有一种方法可以让TamperMonkey在脚本之间的相同扩展内交换消息 - 特别是如果它们在同一个二级域上运行.
谁能指出我正确的方向?一两个例子就值得用黄金来衡量.
更新:尽管Gothdo将浏览器标签/窗口之间的Javascript通信引用为包含此问题的答案,但他没有考虑所涉及的跨源策略.该引用问题中的答案都没有为跨源浏览器选项卡通信提供明确的答案,这是该问题的主要观点.我现在已经研究并解决了这个问题,从一些SO和非SO来源获取想法.如果重新打开这个问题,我会发布我的解决方案.
假设我想发送一封电子邮件至 ,recipient@xyz.com
并将密件抄送副本发送至bcc@xyz.com
。
当bcc@xyz.com
他收到电子邮件时,他应该recipient@xyz.com
在收件人字段和bcc@xyz.com
密件抄送字段中看到。
但是当bcc@xyz.com
收到邮件时,他无法recipient@xyz.com
在收件人字段中看到。
我尝试使用邮件编辑器而不是传输来创建和发送电子邮件,但它没有按预期工作。
我也试过 cc 但 cc 没有按预期工作。
const nodemailer = require('nodemailer');
const testAccount = await nodemailer.createTestAccount();
const transporter = nodemailer.createTransport({
host: "smtp.ethereal.email",
auth: {
user: testAccount.user,
pass: testAccount.pass
},
tls: { rejectUnauthorized: false }
});
const mailData = {
from: 'xyz@xyz.com',
to: 'recipient@xyz.com',
bcc: 'bcc@xyz.com',
subject: 'Sample Mail',
html: text
}
const result = await transporter.sendMail(mailData);
console.log('Mail Sent! \t ID: ' + result.messageId); …
Run Code Online (Sandbox Code Playgroud) jQuery的新手,请求帮助解决我遇到的问题.
克隆的表行包含一个<input type="text" name="dt[]" id="dt1">
字段.下面是克隆的模板行.
<table id="MyTable" name="MyTable">
<tr name="tr3" id="tr3">
<td>
<input type="text" name="dt[]" id="dt1">
</td>
<td>
<input type="file" name="fff[]" id="ff1">
</td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
用户可能会创建其中的几个字段,我试图弄清楚如何循环遍历它们并在提交表单之前验证其中是否有文本.
请注意,我必须使用jQuery .on()方法来访问表单元素.循环如何编码?最初,我一直在尝试这个(EDITED):
$(document).on('click','#sub1',function() {
var d1 = $("[name^=dt]").val();
alert(d1);
if (d1 !=""){
$("#TheForm").submit();
} else {
alert("Empty fields!");
}
});
Run Code Online (Sandbox Code Playgroud)
还有这个:
var d1 = $("#dt1").val();
alert(d1);
Run Code Online (Sandbox Code Playgroud)
还有这个:
var d1 = $("#^dt").val();
alert(d1);
Run Code Online (Sandbox Code Playgroud)
但未能获得数据.
编辑:根据要求,此代码克隆行:
$(document).on('click', '#add_row', function() {
$("table#MyTable tr:nth-child(4)")
.clone()
.show()
.find("input, span").each(function() {
$(this)
.val('')
.attr('id', function(_, id) {
var …
Run Code Online (Sandbox Code Playgroud) 我的 Docker 容器无法启动。日志中的错误信息是:
{"message":"OCI runtime create failed: container_linux.go:349: starting container process caused \
"process_linux.go:319: getting the final child's pid from pipe caused \\\"EOF\\\"\": unknown"}
Run Code Online (Sandbox Code Playgroud)
下一步是什么?
jquery ×5
javascript ×4
node.js ×2
ajax ×1
browser ×1
docker ×1
gmail ×1
greasemonkey ×1
nodemailer ×1
php ×1
reactjs ×1
swiftmailer ×1
tampermonkey ×1
typescript ×1
yarnpkg ×1