2
I’m trying to change the color of a div
if the following condition is true, if( @ViewBag == "reservado" )
, but I’m not succeeding, could someone tell me how the code would look with this condition described above?
I’m programming on Asp.NET
To div
that I want to change the color is this:
<div class="num">001</div>
Last code I tried:
function trocaCor(){
var condi = @ViewBag.status;
if( condi == "reservado"){
document.getElementById("num").style.backgroundColor = green;
}
}
but I don’t know if it’s right, I want when the page is loaded that condition (if it’s correct) to be executed.
I also tried the following code:
if( @ViewBag == "reservado" ){
$('.num').css('background-color','#000000');
}
But it didn’t work
Ricardo, Obrigado, got it with the following code: var someStringValue = '@(Viewbag.statusAcomo1)'; if (someStringValue == "reserved") { $('.num1'). css('background-color', '#ffa500'); }
– Victor