Reputation: 1752
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!
Upvotes: 0
Views: 137
Reputation: 1752
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...
Upvotes: 1
Reputation: 268424
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" );
});
});
Upvotes: 7