JSFiddle - React, Tailwind, and code Playground

by Сергей Тарасевич

HTML

<div class="test_class">
  
</div>
<div class="test_class2" data-test="class">
  
</div>
<div class="test_class3" title="class">
  
</div>

JavaScript

TEST = {}

TEST.addContent = function( a, b, c ) {
	if ( c === false ) {
  	$( '.' + a ).html( b );
  
  } else {
  	$( '[data-' + a + ']' ).html( b );
  }
  
}

$( document ).ready(function(){
	TEST.addContent( 'test_class', 'Это тест 1', false );
  TEST.addContent( 'test="class"', 'Это тест 2', true );
  TEST.addContent( 'test="class"', 'Это тест 2', true );
  
});