Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何更改div的颜色_Javascript_Jquery_Html_Css_Angularjs - Fatal编程技术网

Javascript 如何更改div的颜色

Javascript 如何更改div的颜色,javascript,jquery,html,css,angularjs,Javascript,Jquery,Html,Css,Angularjs,我正在angular.js和html中开发一个应用程序,我被困在一个地方 顶部有一个下拉列表,在更改下拉列表时,我想更改一些单元格的背景色,如图中所示。 以下是我的代码片段: HTML页面 <div class="row"> <div class="col col1" style="-webkit-box-shadow: 0 0 20px 0px #999;background-color: #11c1f3;text-align: center;">

我正在angular.js和html中开发一个应用程序,我被困在一个地方

顶部有一个下拉列表,在更改下拉列表时,我想更改一些单元格的背景色,如图中所示。

以下是我的代码片段:

HTML页面

<div class="row">
        <div class="col col1" style="-webkit-box-shadow: 0 0 20px 0px #999;background-color: #11c1f3;text-align: center;">
            <h3 style="color: white">Time Slot</h3>
        </div>
        <div class="col col1" ng-repeat="time in timeArray" style="background-color: #e0e0e0;text-align: center">
            {{time}}
        </div>
    </div>
    <!-- <div id="selectedDateRange"> -->
    <div class="row" ng-repeat="(dateindex, date) in dateArray">
        <div class="col col1" style="-webkit-box-shadow: 0 0 20px 0px #999;background-color: #11c1f3;text-align: center;">
            <h3 style="color: white">{{date}}</h3>
        </div>
        <div class="col col1" ng-repeat="(timeindex, time) in timeArray" ng-click="selectCell(dateindex, timeindex)" ng-class="{'selected': selectedCell[0] == dateindex && selectedCell[1] == timeindex}"></div>
    </div>
如何更改单元格的背景色


请提前帮助和感谢

ng repeat中使用
track by$index

然后在细胞的内部,像

color:$index==1?'红色“:“绿色”


或者在
ng repeat
中使用
track by$index

然后在细胞的内部,像

color:$index==1?'红色“:“绿色”


或者使用

我认为您可以通过使用这种代码来更改您的内容(可能是增强的,但您有第一个想法)


时隙
{{time}}
{{date}}

你只需要在好的单元格上应用背景(可能设置布尔值?

我认为你可以通过使用这种代码来更改内容(可能是增强的,但你有第一个想法)


时隙
{{time}}
{{date}}

你只需要在好的单元格上应用背景(设置一个布尔值?

当处理类似的东西时,我喜欢在重复的东西上添加一个id元素,然后在onclick pass中像你一样传递元素,然后你可以使用jQuery或任何你喜欢的方法来更改它

<div class="row" ng-repeat="(dateindex, date) in dateArray">
  <div class="col col1" style="-webkit-box-shadow: 0 0 20px 0px #999;text-align: center;">
    <h3 style="color: white" id="dateArray_{{dateindex}}>{{date}}</h3>
  </div>
  <div class="col col1" ng-repeat="(timeindex, time) in timeArray" ng-click="selectCell(dateindex, timeindex)" ng-class="{'selected': selectedCell[0] == dateindex && selectedCell[1] == timeindex}"  ng-style="{'background-color':currentColor}"></div>

当处理这样的事情时,我喜欢在重复的事情中添加一个id元素,然后在onclick中像您一样传递元素,然后您可以使用jQuery或任何您喜欢的方式来更改它

<div class="row" ng-repeat="(dateindex, date) in dateArray">
  <div class="col col1" style="-webkit-box-shadow: 0 0 20px 0px #999;text-align: center;">
    <h3 style="color: white" id="dateArray_{{dateindex}}>{{date}}</h3>
  </div>
  <div class="col col1" ng-repeat="(timeindex, time) in timeArray" ng-click="selectCell(dateindex, timeindex)" ng-class="{'selected': selectedCell[0] == dateindex && selectedCell[1] == timeindex}"  ng-style="{'background-color':currentColor}"></div>

您可以使用ng类在angular js中应用动态CSS属性

例如:

<p ng-class="bold:isbold"> Applying properties Dynamically </p>
<input type="checkbox" ng-model="isbold">make text bold
动态应用属性

使文本加粗
无论何时isbold的值为true,都将应用粗体属性

另外,您可以在ng类中应用多个属性


您可以使用ng类在angular js中应用动态CSS属性

例如:

<p ng-class="bold:isbold"> Applying properties Dynamically </p>
<input type="checkbox" ng-model="isbold">make text bold
动态应用属性

使文本加粗 无论何时isbold的值为true,都将应用粗体属性

另外,您可以在ng类中应用多个属性


我是angular.js的新手,你能为
ng style
写些代码吗?我是angular.js的新手,你能为
ng style
写些代码吗?我能为
ng style
写些代码吗?你为什么要用jquery
.change()
呢何时可以使用
ng change
<p ng-class="bold:isbold"> Applying properties Dynamically </p>
<input type="checkbox" ng-model="isbold">make text bold