在javascript normaly中,页面重定向可以按照以下参数进行.
window.location = "add-new-cos.jsp?id="+id;
Run Code Online (Sandbox Code Playgroud)
但是这个id值会在GET方法中发送到下一页.但我想用POST方法发送它.有没有办法用javascript ....
我很抱歉这个可怕的问题,希望有人可以帮我改一下,但请查看我的代码:
jQuery(document).ready(function($) {
var content = $('.content');
var text = content.html();
console.log(text);
text = text.replace(/<span>/g, '');
text = text.replace(/<\/span>/g, '');
content.html(text);
console.log(text, content.html());
});
Run Code Online (Sandbox Code Playgroud)
http://jsfiddle.net/tikitariki/cttmngzq/
基本上,我正在删除一些HTML以清除一些样式.我使用该replace()方法删除这些span标签.但是,从阅读文档,我不明白为什么它不删除内部</span>标记<h3>.我不想删除它,这是我的目标,但代码明确表示要删除所有</span>.换句话说,它对我想要使用它的效果太好了,我不确定这是否是预期的行为.
我正在使用jQuery和Wordpress.我不确定他们是否与这个"奖金"功能有关.
<div class="content">
<h1><span>Hey</span></h1>
<h2><span>You</span></h2>
<h3><span>I'm <span class="special">Special</span></span></h3>
</div>
Run Code Online (Sandbox Code Playgroud)
这是一个问题的原因是因为没有文档似乎引用这种HTML标签保护能力replace().我喜欢使用Mozilla的文档.https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace
我正在尝试将值从html页面传递给JS文件.
HTML部分:
<a href="#" id="pagejs_general_delete_wizardresultid"><i class=" icon-bin" ></i> Delete</a>
Run Code Online (Sandbox Code Playgroud)
JS档案:
$('#pagejs_general_delete_wizardresultid').on('click', function() {
swal({
title: "Are you sure?",
text: "Are you sure you want to delete item with reference <wizardresultid here>? This can not be undone!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#EF5350",
confirmButtonText: "Yes, delete it!",
cancelButtonText: "No, cancel!",
closeOnConfirm: false,
closeOnCancel: false
},
function(isConfirm, wizardresultid){
if (isConfirm) {
swal({
title: "Deleted!",
text: "The record has been deleted.",
confirmButtonColor: "#66BB6A",
type: "success"
});
}
else {
swal({
title: "Cancelled",
text: …Run Code Online (Sandbox Code Playgroud) 我想获取“atName”类中 div 内的文本。
我循环表 td 是这样的:
var searchString = document.getElementById("search").value;
if (searchString !== "") {
var cols = document.querySelectorAll('#theTable td'),
colslen = cols.length,
i = -1;
while (++i < colslen) {
if (cols[i].id.indexOf(searchString) > -1) {
cols[i].style.opacity = "1"
} else {
Here i want to access the text inside the div
}
Run Code Online (Sandbox Code Playgroud)
每个 td 都是这样设置的:
<td id="H" class="element nonmetal gasI">
<div class="atN">1</div>
<div class="atS gas"><a class="gas" href="https://en.wikipedia.org/wiki/Hydrogen" target="_blank">H</a></div>
<div class="atName">Hydrogen</div>
<div class="atW">1.00794</div>
</td>
Run Code Online (Sandbox Code Playgroud)
我想要“atName”div 中的文本。
有人知道怎么做吗?
谢谢!
我有4个用户密码要求:
.!@#$%^&*()_但是,用户必须满足4个条件中的2个以上.
密码VVVV1111,!234567,AaAaAaAa或者A1!aA1!a是有效的,密码VVVVVVVV,12345678,aaaaaaa,!!!!!!!都没有.
如何制作2个4或者正则表达式中的2个?
我想出了3个条件(AZ,az和0-9):
^((?=.*?[A-Z])|(?=.*?[0-9]))((?=.*?[a-z])|((?=.*?[A-Z])(?=.*?[0-9]))).{8,30}$
Run Code Online (Sandbox Code Playgroud)
但我认为必须有一个更好的选择,因为这个正则表达式在第四个条件下变得非常大.
我收到错误消息“找不到变量uploadImageAsync”
uploadImageAsync = async (uri) => {
console.log("In upload image asnyc!");
}
Run Code Online (Sandbox Code Playgroud)
这就是我所说的。
_handleImagePicked = async pickerResult => {
let uploadResponse, uploadResult;
this.setState({ uploading: true });
if (!pickerResult.cancelled) {
uploadResponse = await uploadImageAsync(pickerResult.uri);
uploadResult = await uploadResponse.json();
this.setState({ image: uploadResult.location });
}
this.setState({ uploading: false });
};
Run Code Online (Sandbox Code Playgroud)
我该如何解决?
到目前为止,我已经尝试过:
async function uploadImageAsync(uri) {
Run Code Online (Sandbox Code Playgroud)
我也尝试过:
async uploadImageAsync(uri) {
Run Code Online (Sandbox Code Playgroud) 我知道如何在页面上设置<img>类或全局到页面上的所有图像上的ALT 标记,但是如何对没有 id 或类的特定图像执行此操作?我可以以某种方式使用父 DIV 来引用图像并添加 alt 标签吗?
<div id="table_processing">
<img src="processing_report.gif"> Loading Report List...
</div>
Run Code Online (Sandbox Code Playgroud) 我有一个下面的数组。我想知道selectedOption对象数组中存在多少时间键。在某些对象中,我们没有 key selectedOption。所以,key的计数selectedOption 应该返回4。我们如何在javascript中计算这些key?
let data = [{
id: 123,
selectedOption: "ABC",
value: 345
}, {
id: 234,
selectedOption: "BCD",
value: 345
}, {
id: 356,
selectedOption: "BGY",
value: 678
}, {
id: 456,
selectedOption: "BCD",
value: 890
}, {
id: 870: value: 980
}, {
id: 385,
value: 654
}]
Run Code Online (Sandbox Code Playgroud) 我有一个这样的数组变量:
dateArray = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
Run Code Online (Sandbox Code Playgroud)
现在我想删除前12个元素dateArray.我尝试了下面的代码,但它仍然没有工作.我用过,splice但我不知道我错过了什么.
if(dateArray.length>12){
for(var d= 0; d <12; d++){
dateArray.splice(d);
}
console.log(dateArray);
}
Run Code Online (Sandbox Code Playgroud)
它输出空数组: []
我想要它只删除前12个输出应该是:
[31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
Run Code Online (Sandbox Code Playgroud)
任何帮助将非常感激.
我正在学习 Node.js。
我必须在循环work()内调用异步函数Promise.all(),并且必须在继续执行 Promise.all() 之后的语句之前完成该函数。目前,它到达了FINISH未完成的状态work()。
让代码等待 work() 函数完成的正确方法是什么?
const promise1 = Promise.resolve(1);
const promise2 = Promise.resolve(2);
const promise3 = Promise.resolve(3);
async function work() {
await new Promise((resolve, reject) => {
setTimeout(resolve, 2000, 'foo');
})
console.log('some work here')
}
async function main() {
await Promise.all([promise1, promise2, promise3]).then((values) => {
values.forEach(function(item) {
console.log(item)
work()
});
});
console.log('FINISH')
}
main()Run Code Online (Sandbox Code Playgroud)
javascript ×10
html ×3
jquery ×3
arrays ×1
async-await ×1
asynchronous ×1
css ×1
node.js ×1
promise ×1
react-native ×1
regex ×1
wordpress ×1