Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

rating star jquery

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<style type="text/css">.bigstar{font-size: 24px;}</style>

<span class="fa fa-star" id="star1"></span>
<span class="fa fa-star" id="star2"></span>
<span class="fa fa-star" id="star3"></span>
<span class="fa fa-star" id="star4"></span>
<span class="fa fa-star" id="star5"></span>

<script type="text/javascript">
	$(document).ready(function(){
		$("#star1").click(function(){
			$(".fa-star").css("color","black").removeClass("bigstar");
			$("#star1").css("color","green");
			$(this).addClass("bigstar");
		});
		$("#star2").click(function(){
			$(".fa-star").css("color","black").removeClass("bigstar");
			$("#star1,#star2").css("color","green");
			$(this).addClass("bigstar");
		});
		$("#star3").click(function(){
			$(".fa-star").css("color","black").removeClass("bigstar");
			$("#star1,#star2,#star3").css("color","green");
			$(this).addClass("bigstar");
		});
		$("#star4").click(function(){
			$(".fa-star").css("color","black").removeClass("bigstar");
			$("#star1,#star2,#star3,#star4").css("color","green");
			$(this).addClass("bigstar");
		});
		$("#star5").click(function(){
			$(".fa-star").css("color","black").removeClass("bigstar");
			$("#star1,#star2,#star3,#star4,#star5").css("color","green");
			$(this).addClass("bigstar");
		});
	});
</script>
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to erase spaces from a string javascript 
Javascript :: sequelize relation does not exist 
Javascript :: check if object has key lodash 
Javascript :: download file from api vue 
Javascript :: axios error 
Javascript :: conditional style react native 
Javascript :: reactjs install 
Javascript :: how to prevent event capturing in javascript 
Javascript :: react inject component into another component 
Javascript :: react cheat sheet 
Javascript :: chart js small bars too thin 
Javascript :: inheritance in es6 
Javascript :: how to sort json objects 
Javascript :: sequelize order with include 
Javascript :: puppeteer mac m1 
Javascript :: express middleware logging 
Javascript :: javascript example of foreach loop 
Javascript :: refresh page by hand in react 
Javascript :: jquery if class clicked 
Javascript :: javascript next month from date 
Javascript :: ternary operator react 
Javascript :: initialize express app 
Javascript :: react js download file 
Javascript :: how to get the div value in jquery 
Javascript :: chartjs begin at 0 
Javascript :: forming an object with reduce 
Javascript :: vscode extensions for better react js 
Javascript :: javascript capitalize 
Javascript :: get current time in different timezone javascript 
Javascript :: check a string for unique characters javascript 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =