My code includes the addition of jQuery
in the script using
import * as $ from 'jquery';
and also adding jQuery
in the HTML file. However, the toggleClass()
function is not functioning correctly. Upon checking the console, there were no errors displayed, it was completely empty.
Displayed below are my HTML and ts code:
HTML Code:
<div class="web" (click) = "myFunc()">
<p>
Web Development
$300
</p>
</div>
// Additional div elements
</div>
<div class="total">
Total
$0
</div>
ts Code:
import { Component } from '@angular/core';
import * as $ from 'jquery';
// Angular component configuration
export class AppComponent {
myFunc() {
$(this).toggleClass("active");
}
}