javascript - style code in jQuery not working -


<!doctype html> <html lang="en">     <head>          <title>          </title>          <meta charset="utf-8" />          <link rel="stylesheet" type="text/css" href="css/custom.css" />     </head>     <body>         <button id="mybutton">my button</button><br /><br />         <span id="mypara"> paragraph</span>           <script type="text/javascript" src="js/jquery-3.1.1.min.js" ></script>     <script type="text/javascript" src="js/custom.js" ></script>     </body> </html> 

below code in custom.css

#mypara{     border: 1px solid black;     color: black;     padding: 5px; } 

below code in custom.js

$('#mybutton','#mypara').on('click',function(){     $(this).css('border-color','white').css('background','black').css('color','white'); }); 

i want apply given css shown in jquery code.

it isn't giving error in console, makes harder me find error.

in browser no css effect showing on click.

i beginner in jquery.

$('#mybutton','#mypara').on('click',function(){ 

in line, first argument css selector , second argument used context. wanted instead:

$('#mybutton,#mypara').on('click',function(){ 

you can find out more how $() function works here.


Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -