jquery add multiple classes
$( "p" ).addClass( "selected highlight" );$( "p" ).addClass( "myClass yourClass" );
$( "p" ).removeClass( "myClass noClass" ).addClass( "yourClass" );
$("p").addClass("myClass yourClass");<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>addClass demo</title>
<style>
p {
margin: 8px;
font-size: 16px;
}
.selected {
color: red;
}
.highlight {
background: yellow;
}
</style>
<script src="https://code.jquery.com/jquery-3.4.1.js"></script>
</head>
<body>
<p>Hello</p>
<p>and</p>
<p>Goodbye</p>
<script>
$( "p" ).last().addClass( "selected highlight" );
</script>
</body>
</html>
Also in JavaScript:
- javascript find textarea
- how to check if a number is negative in p5.js
- Run project in visual studio with iis express
- jquery save method
- chart js line and bar
- transform origin
- set variable with json javascript
- bootstrap 4 modal popup remote url
- flatten nested array javascript
- trigger play video jquery
- js add array items to array
- react suspense chunck
- how to refresh the page using react
- hmac_sha256 node
- validador de cep javascript
- javascript remover acentos
- how to empty table after closing modal using jquery
- array with unique values javascript
- mongoose sparse index
- discord js stats command
- firebase react js
- react native cover image in parent view
- react open on different url instead of localhost
- javascript indexof with condition