Click here to Skip to main content
15,910,212 members
Please Sign up or sign in to vote.
1.80/5 (2 votes)
See more:
how i will use these two in same place
Posted
Updated 6-Apr-15 0:58am
v2

1 solution

JavaScript:

JavaScript
<script>
var myTwoTags = document.getElementsByClassName("className");

function changeColor() {
  myTwoTags.style.color = "#f00"; // red
}
</script>

<button onclick="changeColor()">change color </button>
<h1 class='className'>Change my color</h1>
<p class='className'>Change my color, too</p>


jQuery
JavaScript
$('className').on("click", function() {
    // Statements
})
 
Share this answer
 
Comments
W Balboos, GHB 6-Apr-15 8:00am    
The question was two tags in the same control - you answered two controls with the same tag. Why not modify it to use id and class for changes and get the points for the correct answer?
amin khoshzahmat 6-Apr-15 8:02am    
maybe you are right

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900