简体   繁体   中英

Font-size and Font-family not changing through jquery

hello so this is my code: - code html-

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="icon" href="iconFavicon.png">
    <link rel="stylesheet" href="styles.css">
   
</head>
<body>
<p>My Text Has To Be Changed </>
<button>1</button>
<button>2</button>
<button>3</button>
<button>4</button>
<button>5</button>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="index.js"></script>
</body>
</html>

css-

.text-change{ 
    font-size:2rem;
    font-family:cursive;
    color:black;
}

javascript-

$("p").addClass(".text-change")

Even after writing this statement in javascript i cannot change the font size or the font family of my text. Any kind of help would be appreciated.

There is a little error in your code.

This code: $("p").addClass(".text-change")

Can you change it: $("p").addClass("text-change")

Example here: https://codepen.io/yasgo/pen/MWjWyMp

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM