JSFiddle - React, Tailwind, and code Playground

by Juri Rudi

HTML

<p title="titolo">questo è un paragrafo</p>

<button id="id_attr_get">GET attr</button>
<button id="id_attr_set">SET attr</button>
<button id="id_removeAttr">removeAttr</button>
<br>
<button id="id_hasClass">hasClass</button>
<button id="id_addClass">addClass</button>
<button id="id_removeClass">removeClass</button>
<button id="id_toggleClass">toggleClass</button>
<br>
<button id="id_prop">prop</button>
<button id="id_removeProp">removeProp</button>

CSS

.giallo {
  background-color: yellow;
}

JavaScript

// ATTR (GET)
$("#id_attr_get").click(function(){
	var attributo = $("p").attr("title");
	alert(attributo);
});
// ATTR (SET)
$("#id_attr_set").click(function(){
	$("p").attr("class", "giallo");
});
// REMOVEATTR (GET)
$("#id_removeAttr").click(function(){
	$("p").removeAttr("class");
});

// HASCLASS
$("#id_hasClass").click(function(){
	var attributo = $("p").hasClass("giallo");
	alert(attributo);
});

// ADDCLASS
$("#id_addClass").click(function(){
	$("p").addClass("giallo");
});

// REMOVECLASS
$("#id_removeClass").click(function(){
	$("p").removeClass();
});

// TOGGLECLASS
$("#id_toggleClass").click(function(){
	$("p").toggleClass("giallo");
});

// PROP (SET)
$("#id_prop").click(function(){
	$("p").prop("class", "giallo");
});

// REMOVEPROP 
$("#id_removeProp").click(function(){
	$("p").removeProp("class");
});