jQuery one() method

Configurare noua (How To)

Situatie

The one() method is an inbuilt method in jQuery that attaches one or more event handlers for the selected element. This also attaches a function to run when the event occurs. This method named one because whatever event handler attaches to this method will run only once.

Solutie

Pasi de urmat

 

<!DOCTYPE html>
<html>
<head>
<script src=
“https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js”>
</script>
<script>

// jQuery code to show the working of this method
$(document).ready(function() {
$(“p”).one(“click”, function() {
$(this).animate({
fontSize: “+=14px”
});
});
});
</script>
<style>
.para {
margin: auto;
width: 80%;
border: 3px solid green;
padding: 10px;
text-align:justify;
}
.div1 {
font-size:40px;
color:green;
font-weight:bold;
text-align:center;
}
.div2 {
font-size:17px;
text-align:center;
}
</style>
</head>

<body>
<div class = “para”>
<div class = “div1”>Lorem Ipsum</div>
<div class = “div2”><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.<\p></div>
<p>Pellentesque eu tempus purus, et posuere libero. Integer iaculis rhoncus ligula, a ornare ante maximus quis. Phasellus ut lorem ut diam luctus consectetur. Duis vitae purus sed sapien feugiat efficitur. Aliquam malesuada tortor id lectus semper, sit amet congue sem vehicula. Nunc vehicula lacus eget elit consectetur porta. Fusce eget diam quis sem facilisis fringilla non quis magna. Phasellus viverra enim sed sapien dapibus, non aliquet est lacinia. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Proin eget justo feugiat, tempus mauris nec, ornare dui.</p>
</div>
</body>
</html>

 

Tip solutie

Permanent

Voteaza

(9 din 22 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?