If, Else, and Mobile/Computer screen selectors, Include, Toggle, and Style
- Set up the
react();function
function react(){
return 0;
}- Call the jif or jelse functions before return 0;
- Pass in your variables using
[{var1},{var2}]system
let show = false;
function react(){
jif([{show}]);
}- To actually affect elements you can add the if/else attribute
<p if="show">Show is True!</p>
<p else="show">Show is False!</p>- To hide and show objects if the screen is > or < 600px
- Initiate (outside the react function) with
jmobile(); - To actually affect elements use
mobileandcomputerattributes
<p mobile> Your screen is mobile or <600px </p>
<p computer> Your screen is mobile or >600px </p>- To quickly switch from true or false reactively use
toggle();
let show = false;
function clicked(){
show = toggle(show);
}- To add the contents of a seperate html file to your page
- Initiate (outside the react function) with
include(); - To bring in the data from a separate html file use the
inclattribute
<!--Content.html has <p>Hello World</p> inside-->
<div incl="Content.html"></div>- To style an element in JS by classnames
- Use the
style();function that takes 3 attributes, ClassName, Property, and Change
style("green","color","green");