我这里有一个jsfiddle - http://jsfiddle.net/FTHVJ/
并在这里演示 - http://ttmt.org.uk/select
我知道这看起来有点疯狂,但它是我可以得到的实际代码.
我在选择菜单#menu_One上有一个'更改'事件处理程序
然后添加一个新的选择菜单#menu_Two,它在jquery中保存为变量.
然后我尝试在这个添加的选择菜单中添加一个'更改'事件处理程序.
on'change'事件不适用于添加的选择菜单.
<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
<!--jQuery-->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<!--css-->
<style type="text/css">
*{
margin:0;
padding:0;
}
body{
background:#eee;
}
#wrap{
max-width:800px;
margin:0 auto;
background:#fff;
height:1000px;
padding:50px;
}
#new_select{
height:50px;
margin:20px 0 0 0;
padding:10px 0 0 0;
background:red;
}
</style>
<title>Title of the document</title>
</head>
<body>
<div id="wrap">
<select id="menu_One">
<option>Menu One 1</option>
<option>Menu One 2</option>
<option>Menu One 3</option>
<option>Menu One 4</option>
<option>Menu …Run Code Online (Sandbox Code Playgroud) 我这里有一个页面来说明我的问题
www.ttmt.org.uk/color
它只是具有基色的颜色块,然后我使用sass来减轻和变暗从中心的颜色.
我在这里通过给eavh div(颜色块)一个类名,然后在sass中引用该名称并使基色变亮或变暗来完成它.
这有点像sass所以我在想是否有可能在没有参考sass声明中的那种颜色的情况下使颜色变浅或变暗
所以没有
<div class="at-blue-lightest"></div>
//
at-blue{
background-color: $base-blue;
}
.at-blue-lightest{
background: lighten($base-blue, 30%);
}
Run Code Online (Sandbox Code Playgroud)
我本可以有:
<div class="at-blue lightest"></div>
//
.at-blue{
background-color: $base-blue;
}
.lightest{
background: lighten( 30%);
}
Run Code Online (Sandbox Code Playgroud)
因此,不是参考颜色,它只会使颜色变暗/变暗.
这就是全部
$base-blue: #267EC8;
$base-green: #00A504;
$base-red: #EA002A;
$base-gray: #aaaaaa;
.box{
height: 150px;
margin: 0 10px 10px 0;
width: 150px;
float: left;
}
.con{
overflow: auto;
}
.at-blue{
background-color: $base-blue;
}
.at-red{
background-color: $base-red;
}
.at-green{
background-color: $base-green;
}
.at-blue-lightest{
background: lighten($base-blue, 30%);
}
.at-blue-lighter{
background: lighten($base-blue, …Run Code Online (Sandbox Code Playgroud) 我这里有一个非常简单的例子
它只是一个带有单个div的有角度的应用程序
是否有可能以角度获得div的高度
我以为我可以用@ViewChild和offsetHeight做到这一点
import {Component, ElementRef, ViewChild} from '@angular/core';
@Component({
selector: 'my-app',
templateUrl: './src/app.html'
})
export class AppComponent{
@ViewChild('content') elementView: ElementRef;
contentHeight: number;
constructor() {
}
//contentHeight = this.elementView.nativeElement.offsetHeight
}
Run Code Online (Sandbox Code Playgroud) 在工作中我有一个代理,并在npm中进行设置
npm config set proxy http://theproxy:8080
npm config set https-proxy https://theproxy:8080
Run Code Online (Sandbox Code Playgroud)
没有工作,我没有代理,需要在npm中将其删除。
我试过了
npm config rm proxy
npm config rm https-proxy
Run Code Online (Sandbox Code Playgroud)
和
npm config delete proxy
npm config delete https-proxy
Run Code Online (Sandbox Code Playgroud)
但是当我使用
npm config get proxy
npm config get https-proxy
Run Code Online (Sandbox Code Playgroud)
代理仍然在那里
如何在npm中删除代理
我有一个代码 - https://codepen.io/anon/pen/MQjpBG
这是一个简单的列表,每个 li 中有一个彩色块和文本
我需要垂直的列表和垂直对齐的文本和块。
我正在尝试使用 flex 和 align-items 来做到这一点,但文本和块永远不会完全居中
我做错了什么,有没有更好的方法来做到这一点。
.element{
display: flex;
list-style: none;
&__item{
display: flex;
align-items: center;
margin-right: 10px;
&:last-of-type{
margin-right: 0;
}
&-square{
background: red;
//display: block;
display: inline-block;
height: 20px;
width: 20px;
}
&-text{
font-weight: bold;
}
}
}
Run Code Online (Sandbox Code Playgroud)
我希望块和文本像这样适合。
在align-items: center;似乎做,但它稍微偏离,像
我这里有一个 jsfiddle - https://jsfiddle.net/3e91ropp/
我只是需要一种方法来计算输入字段中不包括空格的字符数。
我需要验证电话号码字段至少有 10 个号码。
我可以使用 length 属性,但这会计算我不想做的空格
$(function() {
$('button').on('click', function() {
console.log($('.field').val().length);
})
});Run Code Online (Sandbox Code Playgroud)
.wrap {
margin: 10px;
}Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="wrap">
<input class="field" type="text" />
<button>Click</button>
</div>Run Code Online (Sandbox Code Playgroud)
我在这里有一个演示
我正在捕获scrollLeft一个滚动的元素。
是否可以用scrollLeft数字更新第二个div,以便两个div一起向左和向右滚动?
元素必须分开,但我需要它们一起滚动。
还是在Angular中有更简单的方法来做到这一点。
我在jQuery的Angular之外进行了此工作,但我不想在Angular中使用jQuery。
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent {
name = 'Angular 5';
isNavbarCollapsed = true;
private scrollLeft: number
//private scrolLTwo: HTMLElement =
onScroll(event: Event) {
this.scrollLeft = (event.target as HTMLElement).scrollLeft;
//console.log(this.scrollLeft);
this.updateScroll();
}
updateScroll(){
//Update second scrolling element
}
}
Run Code Online (Sandbox Code Playgroud) 真的很简单,但我不能解决它.
如何通过单击周围的代码获取下面代码中的图像标题 <a>
$(this,'img').attr('title');
Run Code Online (Sandbox Code Playgroud)
<ul>
<li><a href="01.jpg"><img src="01_th.jpg" title="image_1" /></a></li>
<li><a href="02.jpg"><img src="02_th.jpg" title="image_2" /></a></li>
<li><a href="03.jpg"><img src="03_th.jpg" title="image_3" /></a></li>
</ul>
Run Code Online (Sandbox Code Playgroud)
$(function(){
$('li a').click(function(e) {
e.preventDefault();
var img_href = $(this).attr('href');
var img_title = $(this,'img').attr('title');
alert(img_title); //undefined.
});
});
Run Code Online (Sandbox Code Playgroud) 单击按钮时我隐藏或显示 div。
我想将链接中的文本更改为“显示”/“隐藏”。
我可以正常工作,但是有没有更好的方法来更改文本,而不是检查两个单独跨度上的变量。
<a ng-click="showHint = !showHint"><span ng-if="showHint">Hide</span><span ng-if="!showHint">Show</span> tips</a>
<div ng-if="showHint">
<p>
Hint text Hint text Hint text Hint text
</p>
</div>
Run Code Online (Sandbox Code Playgroud)