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

  • Before and after vs empty tag

    Adding before and after to an non container element is no possible.

    • 7
    • 1
    • 7
    • facebook icon
    • twitter icon
    • google plus
  • Characters limit in textarea

    Limit charecters in textarea without extra space.

    • 232
    • 5
    • 232
    • 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.

    • 265
    • 5
    • 265
    • 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