Skip to content

pjtsearch/Pjt.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

77 Commits
 
 
 
 
 
 

Repository files navigation


Pjt.js is a JavaScript library. Its current main function is converting raw CSS into js styles and toggling CSS.

How to Use

Method 1: Download

  1. Download the latest Pjt.js release.
  2. Link to your page
<script src="pjt.js"></script>

Method 2: No Download

  1. link the latest version of pjt.js to your page
<script src="https://rawgit.com/pjtsearch/Pjt.js/master/pjt.js"></script>

Functions

PCSS.css(css);

Add in raw CSS converted to JS styles.

css: Regular raw CSS (media queries not supported).

example:

PCSS.css(`
body{
background:blue;
border: 1px solid black;
}
#a{
color:red;
border:5px solid green;
}
`);

*Note: back ticks can be used in JS for multi-line strings as shown above.


P(element).toggleCss(style, togglestyle);
Toggles a raw CSS style with another raw CSS style.

element: CSS element selector.
style: Raw CSS style to be toggled with togglestyle (MUST HAVE 1 SPACE AFTER : AND HAVE A ;).
togglestyle: Raw CSS style to be toggled with style (MUST HAVE 1 SPACE AFTER : AND HAVE A ;).

example:
P('#a').toggleCss('color: blue;', 'color: red;');

P(element).toggleCssAny(stylename, value);
Toggles a style value with whatever style value was set before.

element: CSS element selector.
stylename: The name of a JS style.
value: Value of stylename.

example:
P('#a').toggleCssAny('color', 'green');

P(element);
Select a HTML element.

element: CSS element selector.

example:
P('#a');

P(element).html(html);
Replace inner HTML of an element.

element: CSS element selector.
html: Desired new HTML of element (can be HTML).

example:
P('#a').html('test');

P(element).css(css);
Add CSS of an element.

element: CSS element selector.
css: Desired CSS in CSS text.

example:
P('#a').css('color:red; background:blue;');