how to prevent shortcut key event alt + ‘=’ in browser

i am developing contenteditable editor in web browser

i want to prevent alt+’=’ shortcut key event in browser(like chrome, edge, firefox)

When I press the alt+’=’ key, the css effect disappears and the letter spacing becomes wider as in the image below.

enter image description here

enter image description here

It even appears in the browser address bar as above.

The onKeydown event is not controlled, and the Keydown event itself does not occur.

how to prevent alt+’=’ shotrcut key event

Cascade dropdown using static json file

I have 2 dropdown and one auto populate value. the values filled with static json file. Now, I’m trying to cascade the 2 dropdown, but JS script is not working.

What I’m trying to do’s:

Case 1: If the user choose a value from dropdown #1, the value of dropdown #2 depends on dropdown #1.

json file:

note: do not use jQuery.

Jquery ui DatePicker showing NaN-undefined-NaN after input is disabled for spanish users

A Jquery UI Datepicker used in the application to input Date of Birth. Some users are manually inputting date instead of using the datepicker. So to stop this, I disabled the input field. So for normal users, it is working fine. Users can only input date via datepicker.

But I recently received an issue from a user in Bolivia, saying he cant input date with datepicker. When he input date, it shows as NaN-undefined-NaN.

Any idea why this is happening?

Datepicker code:

$("#dateField").datepicker({
     changeYear: true,
     dateFormat: "dd-M-yy",
     yearRange: "-100:+0",
     maxDate: "0",
     onClose: function() {
         $(this).parsley().validate();
     }
});

Screen shots:

enter image description here

enter image description here

why i get wrong element width in js?

my issue is that i want exact width (dynamicly) of my slide-group element. i try many way but each time i got 0px.

html code:

   <div class="slider">
  <div class="slide-group">
    <div class="slide">
      <img
        class="slide-img"
        src="https://picsum.photos/350/200?image=1084"
        alt="image"
      />
    </div>
    <div class="slide">
      <img
        class="slide-img"
        src="https://picsum.photos/350/200?image=1004"
        alt="image"
      />
    </div>
    <div class="slide">
      <img
        class="slide-img"
        src="https://picsum.photos/350/200?image=1044"
        alt="image"
      />
    </div>
  </div>
  
  <div class="slide-group">
    <div class="slide">
      <img
        class="slide-img"
        src="https://picsum.photos/350/200?image=1084"
        alt="image"
      />
    </div>
    <div class="slide">
      <img
        class="slide-img"
        src="https://picsum.photos/350/200?image=1004"
        alt="image"
      />
    </div>
   
  </div>

  <button class="btn right-btn">➡</button>
  <button class="btn left-btn">⬅</button>
</div>

css code :

    body {
  display: flex;
  align-items: center;
  justify-content: start;

  height: 100vh;
}

.slider {
  display: flex;
  
  position: relative;

  width: 1100px;
  margin-inline: auto;
  overflow: hidden;
  border: 1px solid red;
}

.btn {
  background-color: #dcdcdc;
  border-radius: 50%;
  border: none;
  align-self: start;
  padding: .3rem;
  font-size: 1rem;
  cursor: pointer;

  display: flex;
  align-items: center;
  justify-content: center;

  position: absolute;
}

.left-btn {
  top: 50%;
  left: 1%;
  transform: translate(30%, -50%);
}

.right-btn {
  top: 50%;
  right: 1%;
  transform: translate(-30%, -50%);
}

.slide {
  transition: all .5s ease;
}

.slide-group {
  display: flex;
  transition: all .5s ease;
}

.slide-img {
  display: block;
}

js code:

const slideGroupWidth = document.querySelector('.slide-group');
console.log(getComputedStyle(slideGroupWidth).width);

another way that i got 0px:

let box = document.querySelector('.slide-group');
let width = box.offsetWidth;
console.log(width);

why i want width? i want set width of .slide element dynamicly from
.slide-group container.

note: inspect of this element give me 1050px width in chrome.

Is that possible make on screen keyboard using JQUERY and work on any windows app?

I never tried any on screen keyboard. I would wants to know that, will jQuery or JavaScript on screen keyboard work on any windows app or web app, where there is user input focus is ON

On screen keyboard browser windows always open. never be closed or hidden. I am expecting that jQuery or JavaScript should On Screen Keyboard should work on any windows app where user wants to type. Example. notepad, excel, word, there are other apps having text field input.

Unable to edit the label text

I have tried to insert the data into the ToDo List and it is working but i am unable to edit the name and number field in the edit box of ToDo list.

And also the list is showing is not properly having padding and i tried to put padding in the list but whole list is shifting towards the left.

Also I tried with table concept in JavaScript but for that i need the loop and the database but i dont want to use the database or any other storage

var taskInput = document.getElementById("new-task");
var nameInput = document.getElementById("new-name");
var numberInput = document.getElementById("new-number");
var addButton = document.getElementsByTagName("button")[0];
var incompleteTask = document.getElementById("incomplete-tasks");
var completedTask = document.getElementById("completed-tasks");


var createNewTaskElement = function (taskString, nameString, numberString) {

    var listItem = document.createElement("li");

    var checkBox = document.createElement("input");

    var label = document.createElement("label");
    var label1 = document.createElement("label1");
    var label2 = document.createElement("label2");

    var editInput = document.createElement("input");
    var editInput1 = document.createElement("input");
    var editInput2 = document.createElement("input");

    var editButton = document.createElement("button");
    var deleteButton = document.createElement("button");

    label.innerText = taskString;
    label1.innerText = nameString;
    label2.innerText = numberString;

    checkBox.type = "checkbox";
    editInput.type = "text";
    editInput1.type = "text";
    editInput2.type = "text";

    editButton.innerText = "Edit";
    editButton.className = "edit";
    deleteButton.innerText = "Delete";
    deleteButton.className = "delete";

    listItem.appendChild(checkBox);
    listItem.appendChild(label);
    listItem.appendChild(editInput);
    listItem.appendChild(label1);
    listItem.appendChild(editInput1);
    listItem.appendChild(label2);
    listItem.appendChild(editInput2);
    listItem.appendChild(editButton);
    listItem.appendChild(deleteButton);
    alert("You added '" + label.innerText + "' to the ToDO list");
    return listItem;
}

var addTask = function () {
    var listItem = createNewTaskElement(taskInput.value,nameInput.value,numberInput.value);
    if (taskInput.value == "") {
        alert("You must enter a task");
    } 
    else if (nameInput.value == "") {
        alert("You must enter a Name");
    }
    else if (numberInput.value == "") {
        alert("You must enter a Phone Number");
    } else {
        incompleteTask.appendChild(listItem);
        
    }
    bindTaskEvents(listItem, taskCompleted);

    taskInput.value = "";
    nameInput.value = "";
    numberInput.value = "";
}

var editTask = function () {

    var listItem = this.parentNode;

    var editInput = listItem.querySelector('input[type=text]');
    var label = listItem.querySelector("label");
    var containsClass = listItem.classList.contains("editMode");

    if (containsClass) {
        label.innerText = editInput.value;
        alert("You edited " + label.innerText);
    } else {
        editInput.value = label.innerText;
    }
    listItem.classList.toggle("editMode");
}

var deleteTask = function () {
    var listItem = this.parentNode;
    var ul = listItem.parentNode;
    alert("You deleted " + listItem.querySelector("label").innerText);
    ul.removeChild(listItem);
}

var taskCompleted = function () {
    var listItem = this.parentNode;
    completedTask.appendChild(listItem);
    bindTaskEvents(listItem, taskIncomplete);
    alert("You completed " + listItem.querySelector("label").innerText);
}

var taskIncomplete = function () {
    var listItem = this.parentNode;
    incompleteTask.appendChild(listItem);
    bindTaskEvents(listItem, taskCompleted);
}

var bindTaskEvents = function (taskListItem, checkBoxEventHandler) {
    var checkBox = taskListItem.querySelector("input[type=checkbox]");
    var editButton = taskListItem.querySelector("button.edit");
    var deleteButton = taskListItem.querySelector("button.delete");

    editButton.onclick = editTask;

    deleteButton.onclick = deleteTask;

    checkBox.onchange = checkBoxEventHandler;
}

for (var i = 0; i < incompleteTask.children.length; i++) {
    bindTaskEvents(incompleteTask.children[i], taskCompleted);
}

for (var i = 0; i < completedTask.children.length; i++) {
    bindTaskEvents(completedTask.children[i], taskIncomplete);
}

var input = document.getElementById("new-number");

input.addEventListener("keypress", function (event) {
    if (event.key === "Enter") {
        addTask();
    }
});
.container {
    height: 525px;
    width: 450px;
    margin: 100px auto;
}

ul {
    margin: 0;
    padding: 0;
}

li * {
    float: left;
}

li,
h3 {
    clear: both;
    list-style: none;
    font-family: Arial, Helvetica, sans-serif;
}

input,button {
    outline: none;
}

button {
    background: none;
    border: 0px;
    color: #888;
    font-size: 15px;
    width: 60px;
    margin: 10px 0 0;
    font-family: Lato, sans-serif;
    cursor: pointer;
}

button:hover {
    color: #333;
}

h3, label[for='new-task'] {
    color: #333;
    font-weight: 700;
    font-size: 15px;
    border-bottom: 2px solid #333;
    padding: 30px 0 10px;
    margin: 0;
    text-transform: uppercase;
}

input[type="text"] {
    margin: 0;
    font-size: 18px;
    line-height: 18px;
    height: 18px;
    padding: 10px;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 8px;
    font-family: Lato, sans-serif;
    color: #888;
    margin-left: 50px;
}

input[type="text"]:focus {
    color: #333;
}

label[for='new-task'] {
    display: block;
    margin: 0 0 20px;
}

input#new-task,#new-name,#new-number {
    width: 260px;
    margin-bottom: 10px;
}
input:focus{
    outline: none;
    box-shadow: 0px 0px 5px #61C5FA;
    border-color: #5AB0DB;
}

input:hover {
    border: 1px solid #999;
    border-radius: 5px;
}

p>button:hover {
    color: #0FC57C;
}

li {
    overflow: hidden;
    padding: 20px 0;
    border-bottom: 1px solid #eee;
}

li>input[type="checkbox"] {
    margin: 0 10px;
    position: relative;
    top: 15px;
}

li>label {
    font-size: 18px;
    line-height: 40px;
    width: 190px;
    padding: 0 0 0 11px;
}

li>input[type="text"] {
    width: 180px;
}

#completed-tasks label {
    text-decoration: line-through;
    color: #888;
}

ul li input[type=text] {
    display: none;
}

ul li.editMode input[type=text] {
    display: block;
}

ul li.editMode label {
    display: none;
}

th{
    padding-right: 70px;
}
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="style.css" type="text/css">
    <title>To DO List</title>
</head>

<body style="background-color: #ebeff0">
    <div class="container">

        <h3 style="text-align: center;">Add Task</h3>
        <br>
        <label>Add Task</label>
        <input id="new-task" type="text" required><br>

        <label>Name</label>
        <input id="new-name" type="text" required><br>

        <label>Phone Number</label>
        <input id="new-number" type="text" required><br>

        <h3 style="text-align: center;">Todo</h3>
        
        <ul id="incomplete-tasks">
            
        </ul>

        <h3 style="text-align: center;">Completed Tasks</h3>
        <ul id="completed-tasks">
            
        </ul>

    </div>
</body>
<script type="text/javascript" src="main.js"></script>
</html>

Can Django render a React component that is using React-Router

I was building an application in Django and using templates for the majority of the application as I had simple html pages. I already have a sign in and sign up page as well as some portal pages. I tried react and started using it and building some components with the Django rest framework and I liked it for the majority but now I have the issue of routing. I was migrating the react build folders to the respective Django folders and have Django render the components. However, I built a user list where each user is clickable and takes me to an edit page (admin type). But once I migrated the component it simply did not render while other components rendered normally as they should. This is the list set up

ReactDOM.render(
  <React.StrictMode>
    <Router>
      <App />
    </Router>
  </React.StrictMode>,
  document.getElementById("root")
);

Then I call a id “root” div in the index and that works fine in the react server but it does not render at all when I move it to the Django server. If I remove the router related code and make it a simple component it does render but means I will not be able to use routing from react. I am aware that migrating the build folders and have Django render the components is a bad structure for maintainability but I already started my application and would like to know if what I am seeking is even possible.

How to find frequency count of a word in a html table column and write output in a text file?

I am trying to get the frequency of each word of column ‘Company Registered District’ in the following table in the screenshot.

I tried this post (how to find how many times a word occurs in the html table row which is dynamically created) But I don’t have any knowledge on javascript to understand or implement this in my case. Also I would like frequency of each unique word in a text list. Can I achieve this with javascript? If so, how?

Table view

Table structure

Is order of multiple useEffect as well as their cleanup functions guaranteed in React 17?

Let’s say we have 3 useEffect calls with effect2 having a dependency on props.abc while effect1, effect3 have no dependency.

  1. Would execution order of functions be guaranteed effect1 > effect2 > effect3 after mount?
  2. Would execution order of functions be guaranteed effect1Clean > effect2Clean > effect3Clean after unmount?
  3. Is cleanup run after component is removed from DOM as well as UI?

Can someone please help in understanding with clarity?
It gets very confusing with just one line answers like cleanup is fired asynchronously to let browser paint.
Also

function Comp(props) {
  useEffect(function effect1(){return function() effect1Clean{}}, []);
  useEffect(function effect2(){return function() effect2Clean{}}, [props.abc]);
  useEffect(function effect3(){return function() effect3Clean{}}, []);

  return (<div>hi</div>);
}

I have went through multiple similar Stackoverflow questions and Github issues, shared below. But either they are subtly different or too old and not relevant now.

  1. What’s useEffect execution order and its internal clean-up logic in react hooks?
  2. What is the correct order of execution of useEffect in React parent and child components?
  3. https://github.com/facebook/react/issues/16728

clear interval not working with if else condition

    <div class="box" style="margin-top:80px;margin-bottom:80px">

            <div class="back">

            <div class="container skills set" id="set">

                <span id="percent">100</span><span>%</span>

            </div>

            </div>

      <div ><span id="damage">2000</span><span>/2000</span></div>

        </div>
<button  onclick="cli()" >click me </button>

Above is the html and below is the js

    var health = parseInt(document.getElementById("damage").innerHTML);

        if(health > 0){

       var myInterval = setInterval(cli, 1000); 

    }

    else {

        clearInterval(myInterval);
console.log("sttoped");
    }

    

function cli(){

    var rand = Math.floor(Math.random() *1000)+1;

    console.log("running");

     var on=document.getElementById("percent");

    var content = document.getElementById("set");

 health = health - rand;

var calc = Math.floor((health/2000)*100);

document.getElementById("damage").innerHTML = Math.floor(health);

if(health < 0){

    document.getElementById("damage").innerHTML = 0;

    content.style.width = 0;

    on.innerHTML = "0";

}

 else{

    on.innerHTML = calc;

        content.style.width = `${calc}%`;

 

}

    }

    

I am trying to run the function per 1 sec only if the health is above 0 and stop the interval if it drops below 0, but it’s not working and it’s not showing any error on console, any help would be greatly helpful. Here is the codepen link for live preview and test.

How to close a modal with Javascript?

I have 6 different modals. Each modal has a exit button named ‘modal-box__exit-button’. I have tried out some JS to get the modals to close when a user clicks the exit button but I must be writing it wrong. Here is my code:

const btns = document.querySelectorAll("[data-target]");
  const closedModal = document.querySelectorAll(".modal-box__exit-button");

  btns.forEach(btn => {
    btn.addEventListener('click', () => {
      document.querySelector(btn.dataset.target).classList.add('modal-pop-up--active');

      if (typeof window != 'undefined' && window.document) {
        document.body.style.overflow = 'hidden';
      }
    })
  })

  closedModal.forEach(btn => {
    btn.addEventListener('click', () => {
      btns.classList.remove('modal-pop-up--active');
    })
  })
<div class="modal-pop-up" id="modal4">
  <div class="modal-block">
    <div class="modal-box__exit-button">
      <svg stroke="currentColor" fill="currentColor" stroke-width="0" version="1.2" baseProfile="tiny"
        viewBox="0 0 24 24" class="btn" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg">
        <path
          d="M17.414 6.586c-.78-.781-2.048-.781-2.828 0l-2.586 2.586-2.586-2.586c-.78-.781-2.048-.781-2.828 0-.781.781-.781 2.047 0 2.828l2.585 2.586-2.585 2.586c-.781.781-.781 2.047 0 2.828.39.391.902.586 1.414.586s1.024-.195 1.414-.586l2.586-2.586 2.586 2.586c.39.391.902.586 1.414.586s1.024-.195 1.414-.586c.781-.781.781-2.047 0-2.828l-2.585-2.586 2.585-2.586c.781-.781.781-2.047 0-2.828z">
        </path>
      </svg>
    </div>
    <div class="modal-content-inner">
      <h5>{{ pages['why-we-dont-offer-free-shipping'].title }}</h5> 
      <p>{{ pages['why-we-dont-offer-free-shipping'].content }} </p>
    </div>
    <div class="modal-box__contact-button">
      <a href="/pages/contact-us" class="bottom-button">Contact Us</a>
    </div>
  </div>
</div>

(Each modal is the same structure just the info inside changes).