我getElementByClassName()没有返回任何结果,我把它设置为getElementById(),但我不能使用,Id因为相同的功能将需要应用于七个链接.我已经填写了有关jsFiddle的所有信息
javascript看起来像:
var myBoxWidth = 0;
var myBoxWidth2 = 0;
// show
function show() {
var myBox = document.getElementByClassName('box');
var myContent = document.getElementByClassName('content');
myContent.style.display = 'inline';
myBox.style.width = myBoxWidth + '%';
if(myBoxWidth < 80) {
myBoxWidth += 20;
setTimeout(show,55);
}
}
// hide
function hide() {
var myBox = document.getElementByClassName('box');
var myContent = document.getElementByClassName('content');
myContent.style.display = 'none';
var currentWidthVal = parseInt(myBox.style.width,10);
if(myBoxWidth2 < currentWidthVal) {
setTimeout(hide,55);
myBox.style.width = currentWidthVal = currentWidthVal - …Run Code Online (Sandbox Code Playgroud) 我正在 Angular 7 中工作,我的要求之一是使用 mat-icons 创建一个 mat-select。我遇到的问题是我可以显示图标,也可以显示选项标签,但不能同时显示两者。我需要做的是能够链接该值,但是当我尝试时出现错误。
垫子选择设置如下-
<button mat-raised-button type="button" name="button" color="primary" class="roundedButton">
<mat-select [(value)]="selected2">
<mat-select-trigger><mat-icon>{{selected2}}</mat-icon>{{selected2}}</mat-select-trigger>
<mat-option *ngFor="let food of foods" [value]="food.value">
<mat-icon>{{food.icon}}</mat-icon>{{food.viewValue}}
</mat-option>
</mat-select>
</button>
</mat-form-field>
Run Code Online (Sandbox Code Playgroud)
我已将选定的图标和标签放置在 mat-select-trigger 中,并将值放置在 food.value 中。
选择的界面是
export interface Food {
value: string;
viewValue: string;
icon: any;
}
Run Code Online (Sandbox Code Playgroud)
并且选择选项设置为
foods: Food[] = [
{value: 'steak-0', icon: 'add', viewValue: 'Steak'},
{value: 'pizza-1', icon: 'lock', viewValue: 'Pizza'},
{value: 'tacos-2', icon: 'search', viewValue: 'Tacos'}
];
public selected2 = 'steak-0';
Run Code Online (Sandbox Code Playgroud)
如果我将值更改为 food.icon,我可以让选择选项图标显示为选择。如果我将 value 更改为 food.viewValue 我会看到选项的标签出现。
当用户做出选择时,如何才能同时获得两者? …