R K R K - 1 year ago 132
CSS Question

style code in jQuery not working

<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8" />
<link rel="stylesheet" type="text/css" href="css/custom.css" />
<button id="myButton">My Button</button><br /><br />
<span id="myPara"> My paragraph</span>
<script type="text/javascript" src="js/jquery-3.1.1.min.js" ></script>
<script type="text/javascript" src="js/custom.js" ></script>

below is code in

border: 1px solid black;
color: black;
padding: 5px;

below is code in


I want to apply the given css as shown in the jquery code.

It also isn't giving any error in console, which makes it harder for me to find the error.

In my browser no css effect is showing on click.

I am a beginner in jQuery.

Answer Source

In this line, the first argument is a CSS selector and the second argument is used for context. You probably wanted this instead:


You can find out more about how the $() function works here.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download