0%

Hey! Do you have any query related to front end?

Sign in Sign up

Image selection like checkboxBack

Image selection like checkbox

Few lines of code make the selection of image like a checkbox. It is just a toggling of class through jquery. But appearance is new.

jQuery:

$(document).ready(function(){
var countSelected = 0;
//Select image
$('.imageSelecor ul').children().click(function(){
	if($(this).hasClass("imageSelected")){
		$(this).removeClass("imageSelected");
		countSelected--;
	}else{
		$(this).addClass("imageSelected");
		countSelected++;
	}

	$("#status span").html(countSelected);
});
});

Click function plays on the children of UL that is LI, and "hasClass()" detects wether the clicked LI has "imageSelected" class present. If yes the remove the class, or if not then, add the class. Thats it.

How to comment:

  • Create an account in discuss by clicking on login next to arrow.
  • Create password for discuss and varify your email id, through your mail.
  • Refresh page and comment.

You might also like

  • Centralize your content

    Position your content according to your choice

    • 272
    • 5
    • 272
    • facebook icon
    • twitter icon
    • google plus
  • Css3 solar system

    Css3 keyframe animation is an awesome feature, which facilitate us to animate element on the page.

    • 351
    • 14
    • 351
    • facebook icon
    • twitter icon
    • google plus
  • Bubbler popup

    This bubbler effect is created by CSS3 transform

    • 332
    • 11
    • 332
    • facebook icon
    • twitter icon
    • google plus

Latest quries posted

gopa kumarabout 3 years ago

amit singhabout 3 years ago

rahmat aliabout 3 years ago

mandavi tiwariabout 3 years ago

rahul sharmaabout 3 years ago

Ask question
Latest video
Learn Angular
Profile pic
Guest Back
Username
Password