我function error()的工作不是从 php 代码调用。所以请帮助我解决这个问题。在 php 代码之外调用时,fucntion 可以正常工作。但是在 php 代码中调用时没有显示输出。
<html>
<head>
<title>Login Page</title>
<link rel="stylesheet" href="css/design.css">
<script type="text/JavaScript">
function error(){
document.getElementById("wrong-attempt").innerHTML="Wrong Username Or Password";
}
</script>
<?php
if(isset($_POST['submit'])){
echo '<script> error(); </script>';
}
?>
</head>
<body background="pics/background.jpg">
<div class="wrapper">
<center>
<div class="form-wrapper">
<form action="index.php" method="POST">
<div>
</div>
<h1>User Login</h1>
<div>
<img src="pics/login.png" width="100" height="100"/>
</div>
<div>
<input name="ID" placeholder=" Username" type="text" required="true"/></br>
<input name="pass" placeholder=" Password" type="password" required="true"></br>
<input type="image" src="pics/loginb.png" name="submit" value="Login" width="100"/>
</div>
</form>
<div id="wrong-attempt"> …Run Code Online (Sandbox Code Playgroud) 我有问题,DIV内的照片没有显示.由于我使用的是砌体网格,而网站就像是Pinterest,我不想限制图像或内部的高度,所以我把auto,但是当我把auto,或100%,图像没有显示时,我的代码在下面.
.inner {
background-color: rgb(255, 255, 255);
padding-bottom: 40px;
height:auto;
position: relative;
overflow: hidden;
border: 2px solid #ECECEC;
margin-bottom: 30px;
}
.image-box {
position:relative;
height: auto;
width: 100%;
padding-right: 0px;
padding-left: 0px;
background-position: center;
background-color: #4D4E56;
}
.image-box .img{
width: 100%;
display: block;
float: left;
background-repeat: no-repeat;
background-size: cover;
}Run Code Online (Sandbox Code Playgroud)
<div class="inner">
<a href="{{ link }}"><div class="image-box" style="background-image:url(http://placehold.it/350x550)"></div></a>
</div>Run Code Online (Sandbox Code Playgroud)
我有一个包含对象数组的数组.这是一个例子:
[ [{name: Alex, number: 2}, {name: Bill, number: 3}], [{name: John, number: 5}, {name: Aston, number: 7}]]
Run Code Online (Sandbox Code Playgroud)
我想创建另一个数组,其中包含上述数组数组的所有对象,如下所示:
[{name: Alex, number: 2}, {name: Bill, number: 3}, {name: John, number: 5}, {name: Aston, number: 7}]
Run Code Online (Sandbox Code Playgroud)
我写了下面的代码:
const productsInfoArray = [];
const productsRecords = customerContacts.map(i => i.products).map(product => {
product.map(i => productsInfoArray.push(i));
return productsInfoArray;
});
Run Code Online (Sandbox Code Playgroud)
但是当我console.log(productsRecords)返回一个包含所有信息的数组数组时.问题是此数组包含所需数组的12倍,因为customerContacts长度为12
我有一组这样的单选按钮输入:
<input type="radio" name="fruit" id="pear">
<input type="radio" name="fruit" id="apple">
<input type="radio" name="fruit" id="banana">Run Code Online (Sandbox Code Playgroud)
有没有一种方法可以在不使用jQuery 的情况下获取选中的单选按钮输入的 id ?
感谢您的帮助。
我知道我可以得到所选元素的值,如下所示:
console.log(
jQuery('.foo select option:selected').val()
);Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="foo">
<select>
<option>A</option>
<option>B</option>
<option selected>C</option>
<option>D</option>
</select>
</div>Run Code Online (Sandbox Code Playgroud)
但是,如果我使用选项初始化变量,它是如何工作的?我试过这样,但没有成功:
var $option = jQuery('.foo select option');
console.log(
$option.find("selected").val()
);Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="foo">
<select>
<option>A</option>
<option>B</option>
<option selected>C</option>
<option>D</option>
</select>
</div>Run Code Online (Sandbox Code Playgroud)
我是一个JS新手试图从一组json地图中提取一些值.地图是这样的:
var tags = [{
Key: 'backup',
Value: 'true'
},
{
Key: 'Name',
Value: 'sdlc-root'
}
]
// Here is my first attempt:
var volName = tags.filter(function(item) {
return item.Key === 'Name';
})
.map(result => {
return result.Value;
});
console.log(volName);Run Code Online (Sandbox Code Playgroud)
结果是: [ 'sdlc-root' ] ,但我只需要String值.
我现在采取的临时解决方案是:
var volName = tags.filter(function(item) { return item.Key === 'Name'; })
.map(result => { return result.Value; })**[0]**;
console.log(volName);
Run Code Online (Sandbox Code Playgroud)
结果是: sdlc-root
我讨厌我的临时解决方案,并希望听到一些改进建议或经验丰富的开发人员的替代方案
我正在尝试生成随机数,并在每次页面加载时将其显示在div中.问题是它不起作用,并且最重要的是浏览器中的js控制台与某些令牌有问题.我认为他们是对的(下面的代码),但即使我试图改变它们,它仍然说同样的事情.你知道问题出在哪里吗?谢谢!
window.addEventListener('load', function() {
function generateRandomNumber();
document.querySelector("#text").textContent = "The number is " + rnum + ".";
})
function generateRandomNumber() {
var rnum = (Math.floor(Math.random() * 20) + 1);
return rnum;
}Run Code Online (Sandbox Code Playgroud)
<div id="count">
<div id="text">
</div>
</div>Run Code Online (Sandbox Code Playgroud)
我正在尝试从包含以下许多 div 的网页中提取内容(显然所有数据都具有不同的数据,除了初始部分):
<div data-asin="B007R2E578" data-index="0"
class="sg-col-20-of-24 s-result-item sg-col-0-of-12 sg-col-28-of-32 sg-col-16-of-20 AdHolder sg-col sg-col-32-of-36 sg-col-12-of-16 sg-col-24-of-28">
<div class="sg-col-inner">
Run Code Online (Sandbox Code Playgroud)
所有这些 div 的开头都相同:<div data-asin=
我正在尝试使用 Beautifulsoup 中的 find_all 函数提取所有这些:
structure = soup.find_all('div','data-asin=')
Run Code Online (Sandbox Code Playgroud)
但是它总是返回一个空列表。
我不想使用正则表达式。
BeautifulSoup中是否有任何函数可以获取所有这些div?
我试图在包含target =“ _ blank”属性的网页中选择所有锚标签。
我搜索了其他问题,但找不到合适的解决方案。
<a href="https://wclink.co/link/22523/121674/4/83501"
data-store="Frontgate" data-vars-store="Frontgate"
data-vars-outbound-link="https://wclink.co/link/22523/121674/4/83501" rel="nofollow"
target="_blank"
data-gtm-trigger="callout_product_link_button"><span>$30</span> from <span>Frontgate</span></a>
Run Code Online (Sandbox Code Playgroud)
我想使用javascript / jquery在整个页面中包含一个包含所有target =“ _ blank”的列表或数组对象。
谢谢
我有以下代码:
请参阅此处的 codepen 示例:https://codepen.io/Rubenkretek/pen/VwYQVgO ?editors=1111
预期结果:单击“+”按钮时输入字段会增加 1。
实际结果:输入没有变化,出现以下错误:
类型错误:selectedInput.stepUp 不是函数
$(function() {
$('<span class="add" uk-icon="plus">+</span>').insertAfter('.product-container .product-quantity input');
$('<span class="sub" uk-icon="minus">-</span>').insertBefore('.product-container .product-quantity input');
$('.add').click(function() {
var selectedInput = $(this).prev('input');
if (selectedInput.val() < 10) {
console.log("value is less than 10");
$('.add').click(function() {
selectedInput.stepUp(1);
});
}
});
});Run Code Online (Sandbox Code Playgroud)
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="product-container">
<div class="product-info">
<h2>Product name</h2>
</div>
<div class="product-quantity">
<input type="number"></input>
</div>
</div>Run Code Online (Sandbox Code Playgroud)