I got a problem for a long time trying to figure this out but it doesn't work. I'm trying to disable all class that has onmouseover="" and onmouseout="".
So, I tried the following code.
document.getElementsByClassName("Randclass").onmouseout = false;
document.getElementsByClassName("Randclass").onmouseover = false;
Unfortunately, it's not working. Could anyone please help?
I just do an example because of my large amount of code
<script>
function stay() {
document.getElementsByClassName("Randclass").onmouseout = false;
document.getElementsByClassName('Randclass').onmouseover = false;
}
</script>
<button class="Randclass" onmouseover="Somthing" onmouseout="Somthing" onclick="stay()"></button>
<button class="Randclass" onmouseover="Somthing" onmouseout="Somthing"></button>
<button class="Randclass" onmouseover="Somthing" onmouseout="Somthing"></button>
<button class="Randclass" onmouseover="Somthing" onmouseout="Somthing"></button>
EDIT:
New problem, I'm also using php but you'll only see html and javascript For now, ok I have multiple form Tags that has the same class name I'm trying to submit a form when I hover/onmouseover, this form is not for filling in information, it is more likely to be showing information targeting to a Iframe, when you hover/onmouseover it will change the src of the iframe to other people information, now the reason I ask this question is because of the other frames is in the way to add friends (Don't worry I'll show you a image)[here][1] and[here][2]
// this is what each form looks like
<form action="php-SM-UserInfo-Menu+Function.php"
target="Menu"
method="POST"
onclick="stay()"
style="z-index: 1;"
class="Offset">
<button id="User-User" onclick="stay()" <?php echo $row["Favor_Color_Two"];?>>
<img id="User-User-Image" src="<?php echo $row['Front_Img'];?>" width="192" height="192" alt="#" />
<div id="User-User-Name">
<?php echo $row['First_Name']." ".$row['Last_Name']; ?>
<div <?php echo $row['Star_Img'];?>>
</div>
<input type="hidden" name="User_ID" value="<?php echo $row['User_ID']; ?>">
</button>
</form>
and
var myVar;
const elements = document.getElementsByClassName("Offset");
function handleMouseOver(e) {
clearTimeout(myVar);
e.submit();
}
function handleMouseOut(e) {
myVar = setTimeout(timeup, 3000);
off.submit();
}
function initMouseEvents() {
Array.from(elements).forEach((element) => {
element.addEventListener('mouseover', handleMouseOver);
element.addEventListener('mouseout', handleMouseOut);
});
}
function stopMouseEvents() {
Array.from(elements).forEach((element) => {
element.removeEventListener('mouseover', handleMouseOver);
element.addEventListener('mouseout', handleMouseOut);
});
}
function stay() {
stopMouseEvents();
timeup();
}
function timeup(){
document.getElementById("Menu").src = "php-SM-User-SearchMenu.php";
}
initMouseEvents();
Lashan Fernando, the reason I didn't check mark yours is because i had form and i needed to submit it but if i did a document.getElementsByClassName("Offset").submit();
it will only do the first one when I hover on a different one! Thanks for The answer. ;)
[1]: https://i.stack.imgur.com/8b77c.png
[2]: https://i.stack.imgur.com/RvBUb.png