title: The reason why JavaScript is not running on the main page of Blazer
body: <p>The reason why JavaScript is not running on the main page of the Blazer, considering that we have access to the main file when running the web application and the link to the JavaScript file, it works correctly, and when you click on it, the code is displayed correctly and completely in the Ceres section. It will be given. But the JavaScript function is not called or is not executed at all. My codes are as follows:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function opeSublist() {
    try {
  
      if (checkFirstList == 0) {
        checkFirstList = 1;
      }
      var checkList = document.getElementById('FirstList');
      checkList.getElementsByClassName('anchor')[0].onclick = function(evt) {
        if (checkList.classList.contains('visible'))
          checkList.classList.remove('visible');
        else
          checkList.classList.add('visible');
      }
    } catch {}
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  
  &lt;head&gt;
    &lt;meta charset="utf-8" /&gt;
    &lt;meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /&gt;
    &lt;title&gt;Blazor App&lt;/title&gt;
    &lt;base href="/" /&gt;
    &lt;link href="css/bootstrap/bootstrap.min.css" rel="stylesheet" /&gt;
    &lt;link href="css/app.css" rel="stylesheet" /&gt;
    &lt;link href="LosacoWeb.Client.styles.css" rel="stylesheet" /&gt;
    &lt;link href="css/app.css" rel="stylesheet" /&gt;
    &lt;script src="multiselect-dropdown.js"&gt;&lt;/script&gt;
    &lt;script&gt;
      navigator.serviceWorker.register('service-worker.js');
    &lt;/script&gt;
    &lt;link href="_content/Blazored.Modal/blazored-modal.css" rel="stylesheet" /&gt;
    &lt;link href="LosacoWeb.Client.styles.css" rel="stylesheet" /&gt;
    &lt;script src="_content/Blazored.Modal/blazored.modal.js"&gt;&lt;/script&gt;
    &lt;script src="js/jquery-2.1.1.min.js"&gt;&lt;/script&gt;
    &lt;link href="manifest.json" rel="manifest" /&gt;
    &lt;link rel="icon" href="images/cropped-lorchlogo-2022-32x32.png" sizes="32x32" /&gt;
    &lt;link rel="icon" href="images/cropped-lorchlogo-2022-192x192.png" sizes="192x192" /&gt;
    &lt;link rel="apple-touch-icon" sizes="512x512" href="images/logoFa512.png" /&gt;
    &lt;link href="_content/Blazor.PersianDatePicker/datepicker.css" rel="stylesheet" /&gt;
  &lt;/head&gt;
  
  &lt;body dir="rtl"&gt;
    &lt;div id="app"&gt;
      &lt;div class="d-flex justify-content-center" style="margin-top:10%;"&gt;
        &lt;div class="flex-column align-items-center"&gt;
          &lt;img src="images/LogoFaNew.png" /&gt;
          &lt;div class="linear-activity"&gt;
            &lt;div class="indeterminate"&gt;&lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div id="blazor-error-ui"&gt;
      Error ...!
      &lt;a href="" class="reload"&gt;Referesh . . .&lt;/a&gt;
      &lt;a class="dismiss"&gt;&lt;/a&gt;
    &lt;/div&gt;
    &lt;script src="_content/Microsoft.AspNetCore.Components.WebAssembly.Authentication/AuthenticationService.js"&gt;&lt;/script&gt;
    &lt;script src="_framework/blazor.webassembly.js"&gt;&lt;/script&gt;
    &lt;script&gt;
      navigator.serviceWorker.register('service-worker.js');
    &lt;/script&gt;
    &lt;script src="js/plugins.min.js"&gt;&lt;/script&gt;
    &lt;script src="js/toastr.min.js"&gt;&lt;/script&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  <p>and the <code>javascript</code> function is inside of <code>multiselect-dropdown.js</code> javascript separate file. But it is not clear to me why this function is not executed and the result is not displayed. In fact, by clicking on a <code>DIV</code>, a list should be displayed, and by clicking outside the list, the list should be removed from the display mode. All steps are correct. And in a normal HTML page, this function is executed correctly. But when transferred to <code>Blazor</code>, it does not run. I do exactly the same things I did on the HTML page in Blazer. But it has no effect.</p>