tb-no-more-get-document-by-id

1.0.7 • Public • Published

Install

npm install tb-no-more-get-document-by-id

copy dist folder to your public directory

<script src="/dist/no-more-get-document-by-id.js"></script>

Description

If You Don't Have jQuery or prototype.js

And If You Are Writing document.getElementById('example');

Then You Can Use $tb('#example').innerHTML = '<div>Content Changed</div>';

The Same For Classes document.getElementByClassName('example');

Then You Have An Array Of The Elements With The class example

let example = $tb('.example') is an array 

so you can loop through the example variable or target the first

$tb('.example')[0];

You Can Do The Same For Tag Names The Same As You Do For Classes

$tb('div')[0];

You Can Then Append Regular JS

TESTS

screenshot

Examples

      //target element with id='test' 
      $tb('#test').innerText = 'Content Changed';
 
      //target all div elements   
      let tb =  $tb('div');

      for(let i =0; i<= tb.length-1; i++) {
           tb[i].innerHTML= 'Content Changed';
      }
      
      //target all elements with a class of example
       let example =  $tb('.example');
  
       for(let i =0; i<= example.length-1; i++) {
           example[i].innerHTML= 'Content Changed';
       }
       
       //input setting and getting values
        $tb('#test').value = 15;
       
        console.log($tb('#test').value);

Package Sidebar

Install

npm i tb-no-more-get-document-by-id

Weekly Downloads

7

Version

1.0.7

License

MIT

Unpacked Size

2.69 kB

Total Files

3

Last publish

Collaborators

  • tuckbloor