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

  • Hanging menu on window scroll

    After scrolling window beyond menu height, a floating bar appears at the top having same menu inside it.

    • 308
    • 12
    • 308
    • facebook icon
    • twitter icon
    • google plus
  • Force other page to scroll

    Scroll other page at specific location, when related link has been clicked in current page.

    • 284
    • 5
    • 284
    • facebook icon
    • twitter icon
    • google plus
  • Real time content edit

    Edit content at client side.

    • 189
    • 1
    • 189
    • 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