我有2行CSS用于在除最后一个元素之外的每个元素上设置边距.有没有办法将它组合成一行?
这就是我目前(工作):
.work img {
margin-right: 10px;
}
.work img:last {
margin-right: 0px;
}
Run Code Online (Sandbox Code Playgroud)
我尝试将其更改为:
.work img:not(:last) {
margin-right: 10px;
}
Run Code Online (Sandbox Code Playgroud)
但它不起作用?知道为什么吗?
更新我只有五张图片.我的另一个选择是只有前四个的利润.
我正在尝试更改复选框的背景颜色和边框,但它不起作用。
HTML:
<label for="checkbox1" class="checkbox">
<input id="checkbox1" type="checkbox" role="checkbox" /><span class="custom">Checkbox</span>
</label>
Run Code Online (Sandbox Code Playgroud)
CSS:
.checkbox input:checked {
border-color: red;
background-color:red;
}
Run Code Online (Sandbox Code Playgroud)
更新:
我无法更改标记
我创建了一个正则表达式来去除空格、制表符、新行等。
(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+
Run Code Online (Sandbox Code Playgroud)
我的问题是它匹配一些空格和一些新行,而不是全部。这是为什么?
我试过了:
(^[\r\n]*|[\r\n]+)[\s\t+]*[\r\n]+
Run Code Online (Sandbox Code Playgroud)
但似乎仍然不匹配多个空格
我希望我的文本框只允许数字,并且也有字符限制。
目前,我的数字正在工作......现在我在弄清楚如何限制字符方面遇到问题。
这是我所拥有的...
JS:
app.directive('numbersonly', function () {
return {
restrict: 'A',
link: function (scope, elm, attrs, ctrl) {
elm.on('keydown', function (event) {
if (event.which == 64 || event.which == 16 && elm.val().length > 4) {
return false;
} else if (event.which >= 48 && event.which <= 57) {
return true;
} else if (event.which >= 96 && event.which <= 105) {
return true;
} else if ([8, 13, 27, 37, 38, 39, 40].indexOf(event.which) > -1 && elm.val().length > 4) …
Run Code Online (Sandbox Code Playgroud) validation input angularjs angularjs-directive angularjs-scope
我必须window.onload
在一个页面上使用多个函数,因为我正在使用的 JS 插件已经调用了该window.onload
函数。我不想编辑该插件并解决它。这是我尝试过的:
<div id="Count"></div>
//<script type="text/javascript" src="plugin.js" /> // JS plugin using window.onload
var INCREMENT = 3;
var count = 0;
var msInterval = 800;
var oldonload = window.onload; // assigning current window.onload to a variable
window.onload = function() { <-- error line
if (oldonload) {
oldonload();
}
document.getElementById('Count').innerHTML = count;
setInterval("count += INCREMENT; document.getElementById('Count').innerHTML = count;", msInterval);
}
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
类型错误:(中间值)(...)不是函数
如果输入为空,我想添加一个类,如果不是,则删除它。我最初有addClass();
所以我尝试使用:
.removeClass().addClass();
Run Code Online (Sandbox Code Playgroud)
但它似乎并没有在单击按钮时更新类。
HTML:
<input id="firstName" type="text" />
<input id="lastName" type="text" />
<a href="#" id="button">SEND</a>
Run Code Online (Sandbox Code Playgroud)
jQuery:
var firstName = $("#firstName");
var lastName = $("#lastName");
$('#button').click(function () {
if(firstName.val() == "" || lastName.val() == ""){
firstName.removeClass("errorInput").addClass("errorInput");
lastName.removeClass("errorInput").addClass("errorInput");
}
if ($(":input").hasClass("errorInput")) {
alert("false");
} else {
alert("true");
}
});
Run Code Online (Sandbox Code Playgroud)
我的选择查询正在返回一个数组...但我希望它返回一个对象
PHP:
$language = DB::select(select query here);
Run Code Online (Sandbox Code Playgroud)
我尝试->get()
在之后添加,但似乎无法将其添加到数组中。