How to change the style of an HTML element (tag) with jQuery

1 Answer

0 votes
<!DOCTYPE html>
<html>
  
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
</head>
  
<body>

<p id="p-id"></p>

<script>        
 
// jQuery

function set_p() 
{
    $("#p-id").attr("style", "color:green").html("jQuery")
}

$(document).ready(set_p);

/*
run:
  
"jQuery" green color text in "p-id"
    
*/

</script>


</body>
</html>

 



answered Jul 30, 2015 by avibootz

Related questions

1 answer 308 views
1 answer 303 views
2 answers 302 views
1 answer 253 views
253 views asked Mar 1, 2021 by avibootz
3 answers 427 views
...