logo
down
shadow

Trouble creating "if then" Javascript statement to change background color of page


Trouble creating "if then" Javascript statement to change background color of page

By : Ajeesh P S
Date : November 29 2020, 09:01 AM
will be helpful for those in need I'm working on a project right now that requires we use Javascripts built in RNG to generate a number from 0-37, and then change the background color from blue to black if the number is odd, and blue to red if the number is even. I'm almost certain I've got the commands right, but I still can't figure out what I'm doing wrong. Just looking for a second set of eyes to glance it over that might spot what I'm doing incorrectly. , No, your "commands" aren't right.
code :
if ('wheel' % 2 == 0) {
function myFunction() {
    var x = Math.floor((Math.random() * 38) + 0);
    document.getElementById("wheel").innerHTML = x;
  
    if (x % 2 == 0) {
      document.body.style.backgroundColor = "red";
    } else {
      document.body.style.backgroundColor = "black";
    }
}
body {
  background-color: blue;
}
<button onclick="myFunction()">Spin the Wheel</button>

<p id="wheel" style="color: white;"></p>


Share : facebook icon twitter icon
How to change background-color of a "li" if I put the cursor in an input field inside the "li"?

How to change background-color of a "li" if I put the cursor in an input field inside the "li"?


By : srinivas d
Date : March 29 2020, 07:55 AM
around this issue You can't do this with pure css, you'll need to use javascript / jQuery:
code :
$("input[type='text']").focus(function(){
    $("li").removeClass("background");
    $(this).closest("li").addClass("background");
});
Can I change the color of text from PUT statement without using "ERROR-"/"WARNING-"/"NOTE-"

Can I change the color of text from PUT statement without using "ERROR-"/"WARNING-"/"NOTE-"


By : Max Khokhlov
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further I believe this was discussed over at communities.sas.com a while ago, and the conclusion was NO. You can't designate a color for specific user-generated text written to the log.
https://communities.sas.com/t5/SAS-Enterprise-Guide/Colorized-Text-in-the-EG-Log/td-p/251828
How to change background color "continuously" without refreshing the page

How to change background color "continuously" without refreshing the page


By : Francesc Requesens
Date : March 29 2020, 07:55 AM
I wish this helpful for you Is here any way to continuously change the background color like a rainbow? , Hope you needed something like this.
code :
var body = $('body');
var colors = ['red', 'green', 'blue', 'yellow', 'pink', 'purple'];
var currentIndex = 0;
setInterval(function () {
   body.css({
     backgroundColor: colors[currentIndex]
   });
   if (!colors[currentIndex]) {
       currentIndex = 0;
   } else {
       currentIndex++;
   }
}, 100);
body {
  transition: 200ms ease;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
How can i change canvas background color with " input color and onchange "

How can i change canvas background color with " input color and onchange "


By : user3342461
Date : March 29 2020, 07:55 AM
will be helpful for those in need You're pretty close. What you could do is add a parameter for myFunction which would be a reference of the input to itself, then use that to set the value. Here's an example of what I mean:
Change the input to this:
code :
<input type="color"  onchange="myFunction(this)">
function myFunction(self) {
    document.getElementById('canvas1').style.background = self.value;
}
WP input box shows white background, even though I change to "background-color: none;" (Themify bulider)

WP input box shows white background, even though I change to "background-color: none;" (Themify bulider)


By : erfan
Date : March 29 2020, 07:55 AM
I wish this helpful for you Could someone help me with an annoying error? , try the following:
code :
.mdc-text-field {
    background-color: transparent !important;
}
Related Posts Related Posts :
  • CRM 2013 Limit the date field
  • fancybox - changing close button color
  • Ember-notify giving error can't read property "Service" of undefined
  • Passport-init.js authentication is not working in nodejs
  • Branch.io Cordova API - init() fails on Android Device
  • appending HTML codes to an elements using js
  • Css animation to extend button text on hover
  • I want to restrict HTML input autocomplete to 3 letter minimum
  • tinyMCE editor not updating on the fly
  • typescript kendo-ui call method from string
  • HttpCompileException was unhandled by user code (when i am adding c# code in script)
  • Send form data as array of objects to controller in asp.net mvc
  • Javascript, multi file modules and Require.Js
  • how to render a complete new template and leave the application template in ember
  • Hover unrelated divs
  • Permute string until it matches some input?
  • How to fire JQuery change event when input value changed programmatically?
  • AJAX: POST data to a different url
  • checkbox column in jquery datatable
  • Document.evaluate for documents without namespaceURI crashes Microsoft Edge
  • Bootstrap Menu with "More" option Responsive issue
  • Standard inputs not being added to Angularjs Form $Scope
  • Express promise throw error
  • onclick and get in jquery
  • How to get the country code from Google Places API
  • Passing parameters url in Select2
  • Is there any frame work for Marklogic to write javascript code?
  • How to implement a boostrap template over bootstrap-sass gem
  • Why fixed div comes out when horizontally scrolled?
  • How to limit scope of a function in javascript/ jquery
  • Overlapping legend d3.js
  • Apply transition to div
  • Javascript game help - counting with dice
  • How to hide a div from angular controller
  • Can Promise load multi urls in order?
  • How enable Hover event for bootstrap menus?
  • D3 scale.invert() isn't returning date for x
  • Parsing object to array using underscore js or lodash
  • ES6 with React and Browserify
  • AngularJS Factory return type undefined
  • javascript follow html input fields
  • how to declare a double array in javascript for this particular UI
  • Jquery : find length of mixed list
  • Returning the array before the function is complete & Angular JS
  • Javascript set value of class & hidden input in nested divs
  • Register custom filters with vue.js
  • Add class to input parent
  • Angular controller not talking to view
  • Socket.IO - Middleware and scoping: how should I access global IO object from external middleware?
  • add class when input is valid in angularjs
  • Positioning multiple div elements
  • Checkbox clicking works, deselecting checkbox not working Javascript
  • Adding ajax jQuery File upload
  • Creating a dynamic array within a dynamic array in JQuery
  • Multiple File Upload actions for a single File Input PHP/JS
  • Want to move an added element to a different part of the DOM
  • Why can't I get Angularjs to work?
  • Minimizing browser window in Firefox & Chrome adds white space to right of page
  • I need to insert the date and time of employee stamp in and out into mysql database
  • Making css auto slider
  • shadow
    Privacy Policy - Terms - Contact Us © animezone.co