In click function all images,
<script type="text/javascript">
$(".blurall").click(function(){
$("[img='.jpg']").addClass("opacity");
});
</script>
My css
.opacity{
opacity:0.5;
}
Not working any one help me!
Make sure your DOM is ready before this can be called. Additionally, you forgot the quotes around your first class selector. I swapped out the old $.click for the preferred $.on. Lastly, updated your selector so that the src must end with .jpg in order to be matched.
$(function(){
$( ".blurall" ).on( "click", function() {
$( "img[src$='.jpg']" ).addClass( "opacity" );
});
});
your selector is wrong, Use img[src$='.jpg'] like this
<script type="text/javascript">
$(".blurall").click(function(){
$("img[src$='.jpg']").addClass("opacity");
});
</script>
try this...
$(.blurall) is also not valid.
$(document).ready(). Oh, and read the jQuery/JavaScript guide for future reference.imgattribute. They usually have asrcattribute (imgis the tag). And usually the URL consists of more than just.jpg([...='...']matches only the exact value).