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

  • Characters limit in textarea

    Limit charecters in textarea without extra space.

    • 266
    • 5
    • 266
    • facebook icon
    • twitter icon
    • google plus
  • Javascript drag and drop

    Very light script for dag and drop

    • 314
    • 4
    • 314
    • facebook icon
    • twitter icon
    • google plus
  • Css3 image blending like photoshop

    CSS3 blend mode blends two background simultaneously like Photoshop blending.

    • 261
    • 4
    • 261
    • 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